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

Add first use case - error handler code #3

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

benjamingr
Copy link
Member

No description provided.

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm


## User Expectation

a thrown error from `getReplyFromDatabaseUsingModules` should get observed at the process uncaught error handler to be logged even if the library error handler does not catch the error.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'm confused; if lib.get does handle the error, then it must not be observed on the uncaught exception handler. perhaps:

Suggested change
a thrown error from `getReplyFromDatabaseUsingModules` should get observed at the process uncaught error handler to be logged even if the library error handler does not catch the error.
a thrown error from `getReplyFromDatabaseUsingModules` must be observed with the process uncaught error handler to be logged if (and only if) the library error handler does not catch the error.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a user expectation I don't suspect they use the RFC "MUST" in how they would describe it 😅

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean im sure they don’t use the terms, but I’m also sure the meaning is what they intend.


We may want to consider that not adding a listener to those events and to instead log these errors by listening to stderr/stdout is a more robust practice that is more resiliant and would work in cases such as the user calling `process.exit` directly. It may be worth it to add a recommenation so users do that however we should consider error handling code being resiliant as a user expectation.

We cannot reasonably make a stronger guarantee such that any error handling code even in userland should be robust to tampering with built ins. For example if the user alters `lib.get` to throw or `EventTarget.on` to throw we cannot guard against that reasonably but ideally the error created would still reach the global Node.js process error handler.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

EventTarget -> EventEmitter


## Out of Scope

We may want to consider that not adding a listener to those events and to instead log these errors by listening to stderr/stdout is a more robust practice that is more resiliant and would work in cases such as the user calling `process.exit` directly. It may be worth it to add a recommenation so users do that however we should consider error handling code being resiliant as a user expectation.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the stderr/stdout could be on scope, because if node core is not reliable, the error logged on stderr might be not as useful as it could be – e.g. a TypeError: undefined is not a function when the error thrown by getReplyFromDatabaseUsingModules has nothing to do with it

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 this pull request may close these issues.

None yet

6 participants