Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Callback was already called" bug #437

Closed
ctaschereau opened this issue Sep 3, 2021 · 1 comment · Fixed by #440
Closed

"Callback was already called" bug #437

ctaschereau opened this issue Sep 3, 2021 · 1 comment · Fixed by #440

Comments

@ctaschereau
Copy link

ctaschereau commented Sep 3, 2021

At this line in the set function, we can see that the callback is in fact inside the try statement. This has the side effect that if some code throws immediately after calling the set function, we will fall inside the catch statement of the set function and then have an "Callback was already called" error.

this.emit('set', sid)
callback(null)
} catch (error) {
callback(error)
}
})()

example code :

session.save(() => {
    throw new Error('some random error happened... (ex : uncaught)');
});

I have tested just moving the "callback" outside of the try/catch statement (and adding a return after the callback that is inside the catch) and the behaviour appears to be correct. I'll try and find the time to submit a proper pull request this weekend.

@mingchuno
Copy link
Collaborator

4.6.0 released

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants