-
Notifications
You must be signed in to change notification settings - Fork 30.7k
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
src: improve error handling in buffer and dotenv #57189
base: main
Are you sure you want to change the base?
src: improve error handling in buffer and dotenv #57189
Conversation
} | ||
|
||
Local<Object> Dotenv::ToObject(Environment* env) const { | ||
MaybeLocal<Object> Dotenv::ToObject(Environment* env) const { | ||
EscapableHandleScope scope(env->isolate()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For educational purposes: why is this needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any JS handles that are created while this is running will be created within whatever handlescope is on the stack. If this method errors, those handles will end up being kept around until that outer scope exits. This ensures that in the error case, any handles created during this function are cleaned up immediately.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we not have this everywhere?
@@ -511,7 +511,7 @@ static void LoadEnvFile(const v8::FunctionCallbackInfo<v8::Value>& args) { | |||
|
|||
switch (dotenv.ParsePath(path)) { | |||
case dotenv.ParseResult::Valid: { | |||
dotenv.SetEnvironment(env); | |||
USE(dotenv.SetEnvironment(env)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't we just throw here, rather than omitting the error?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're not ignoring the error. In this branch we end up immediately breaking and skipping to the end of the function, allowing the error to propagate.
This comment was marked as outdated.
This comment was marked as outdated.
d0e8328
to
9d16f80
Compare
This comment was marked as outdated.
This comment was marked as outdated.
Replacing ToLocalChecked()
9d16f80
to
c8d7c8d
Compare
Replacing ToLocalChecked()