Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/session.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,9 @@ module.exports = class Session {
reload (callback) {
if (callback) {
this[sessionStoreKey].get(this[sessionIdKey], (error, session) => {
this[requestKey].session = new Session(this[requestKey],
this[requestKey].session = new Session(
this[sessionStoreKey],
this[requestKey],
this[generateId],
this[cookieOptsKey],
this[cookieSignerKey],
Expand Down
26 changes: 26 additions & 0 deletions test/session.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,32 @@ test('should reload the session', async (t) => {
t.assert.strictEqual(response.statusCode, 200)
})

test('should save the reloaded session with callback', async (t) => {
t.plan(3)
const fastify = await buildFastify((request, reply) => {
request.session.someData = 'some-data'
request.session.save((err) => {
t.assert.ifError(err)

request.session.reload((err) => {
t.assert.ifError(err)

reply.send(200)
})
})
}, {
...DEFAULT_OPTIONS,
cookie: { secure: false }
})
t.after(() => fastify.close())

const response = await fastify.inject({
url: '/'
})

t.assert.strictEqual(response.statusCode, 200)
})

test('should save the session', async (t) => {
t.plan(6)
const fastify = await buildFastify((request, reply) => {
Expand Down
Loading