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

src: pass along termination exception in fatal TryCatch #25141

Closed
wants to merge 2 commits into from
Closed
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
4 changes: 3 additions & 1 deletion src/module_wrap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -708,7 +708,9 @@ void ModuleWrap::Resolve(const FunctionCallbackInfo<Value>& args) {
return node::THROW_ERR_MISSING_MODULE(env, msg.c_str());
}

args.GetReturnValue().Set(result.FromJust().ToObject(env));
MaybeLocal<Value> obj = result.FromJust().ToObject(env);
if (!obj.IsEmpty())
args.GetReturnValue().Set(obj.ToLocalChecked());
}

static MaybeLocal<Promise> ImportModuleDynamically(
Expand Down
2 changes: 1 addition & 1 deletion src/node_errors.cc
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ void OnFatalError(const char* location, const char* message) {
namespace errors {

TryCatchScope::~TryCatchScope() {
if (HasCaught() && mode_ == CatchMode::kFatal) {
if (HasCaught() && !HasTerminated() && mode_ == CatchMode::kFatal) {
HandleScope scope(env_->isolate());
ReportException(env_, Exception(), Message());
exit(7);
Expand Down
4 changes: 2 additions & 2 deletions src/node_url.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2381,7 +2381,7 @@ URL URL::FromFilePath(const std::string& file_path) {
// This function works by calling out to a JS function that creates and
// returns the JS URL object. Be mindful of the JS<->Native boundary
// crossing that is required.
const Local<Value> URL::ToObject(Environment* env) const {
MaybeLocal<Value> URL::ToObject(Environment* env) const {
Isolate* isolate = env->isolate();
Local<Context> context = env->context();
Context::Scope context_scope(context);
Expand Down Expand Up @@ -2417,7 +2417,7 @@ const Local<Value> URL::ToObject(Environment* env) const {
->Call(env->context(), undef, arraysize(argv), argv);
}

return ret.ToLocalChecked();
return ret;
}

static void SetURLConstructor(const FunctionCallbackInfo<Value>& args) {
Expand Down
6 changes: 1 addition & 5 deletions src/node_url.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@
namespace node {
namespace url {

using v8::Local;
using v8::Value;


#define PARSESTATES(XX) \
XX(kSchemeStart) \
XX(kScheme) \
Expand Down Expand Up @@ -171,7 +167,7 @@ class URL {
// Get the file URL from native file system path.
static URL FromFilePath(const std::string& file_path);

const Local<Value> ToObject(Environment* env) const;
v8::MaybeLocal<v8::Value> ToObject(Environment* env) const;

URL(const URL&) = default;
URL& operator=(const URL&) = default;
Expand Down