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

bootstrap: print stack trace during environment creation failure #46533

Closed
wants to merge 3 commits into from

Conversation

joyeecheung
Copy link
Member

#45888 took the environment creation code out of the scope covered by the v8::TryCatch that we use to print early failures during environment creation. So e.g. when adding something that would fail in node.js, we get

node:internal/options:554: Uncaught Error: Should not query options before bootstrapping is done

This patch restores that by adding another v8::TryCatch for it:

node:internal/options:20
    ({ options: optionsMap } = getCLIOptions());
                               ^

Error: Should not query options before bootstrapping is done
    at getCLIOptionsFromBinding (node:internal/options:20:32)
    at getOptionValue (node:internal/options:45:19)
    at node:internal/bootstrap/node:433:29

nodejs#45888 took the environment
creation code out of the scope covered by the v8::TryCatch
that we use to print early failures during environment creation.
So e.g. when adding something that would fail in node.js, we get

```
node:internal/options:554: Uncaught Error: Should not query options before bootstrapping is done
```

This patch restores that by adding another v8::TryCatch for it:

```
node:internal/options:20
    ({ options: optionsMap } = getCLIOptions());
                               ^

Error: Should not query options before bootstrapping is done
    at getCLIOptionsFromBinding (node:internal/options:20:32)
    at getOptionValue (node:internal/options:45:19)
    at node:internal/bootstrap/node:433:29
```
@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run. labels Feb 6, 2023

TryCatch bootstrapCatch(isolate);
auto print_Exception = OnScopeLeave([&]() {
if (bootstrapCatch.HasCaught()) {
Copy link
Member

Choose a reason for hiding this comment

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

Should this check CanContinue() also?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think the code below should return early when there is an exception, so it's not necessary to check here because what we do should not result in JS execution anyway, just communicating the stack trace back to the caller.

src/api/embed_helpers.cc Outdated Show resolved Hide resolved
src/node_errors.cc Outdated Show resolved Hide resolved
src/node_errors.cc Outdated Show resolved Hide resolved
Co-authored-by: Anna Henningsen <github@addaleax.net>
@nodejs-github-bot
Copy link
Collaborator

legendecas pushed a commit that referenced this pull request Feb 28, 2023
#45888 took the environment
creation code out of the scope covered by the v8::TryCatch
that we use to print early failures during environment creation.
So e.g. when adding something that would fail in node.js, we get

```
node:internal/options:554: Uncaught Error: Should not query options before bootstrapping is done
```

This patch restores that by adding another v8::TryCatch for it:

```
node:internal/options:20
    ({ options: optionsMap } = getCLIOptions());
                               ^

Error: Should not query options before bootstrapping is done
    at getCLIOptionsFromBinding (node:internal/options:20:32)
    at getOptionValue (node:internal/options:45:19)
    at node:internal/bootstrap/node:433:29
```

PR-URL: #46533
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
@legendecas
Copy link
Member

Landed in bff7be8

@legendecas legendecas closed this Feb 28, 2023
targos pushed a commit that referenced this pull request Mar 13, 2023
#45888 took the environment
creation code out of the scope covered by the v8::TryCatch
that we use to print early failures during environment creation.
So e.g. when adding something that would fail in node.js, we get

```
node:internal/options:554: Uncaught Error: Should not query options before bootstrapping is done
```

This patch restores that by adding another v8::TryCatch for it:

```
node:internal/options:20
    ({ options: optionsMap } = getCLIOptions());
                               ^

Error: Should not query options before bootstrapping is done
    at getCLIOptionsFromBinding (node:internal/options:20:32)
    at getOptionValue (node:internal/options:45:19)
    at node:internal/bootstrap/node:433:29
```

PR-URL: #46533
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
targos pushed a commit that referenced this pull request Mar 14, 2023
#45888 took the environment
creation code out of the scope covered by the v8::TryCatch
that we use to print early failures during environment creation.
So e.g. when adding something that would fail in node.js, we get

```
node:internal/options:554: Uncaught Error: Should not query options before bootstrapping is done
```

This patch restores that by adding another v8::TryCatch for it:

```
node:internal/options:20
    ({ options: optionsMap } = getCLIOptions());
                               ^

Error: Should not query options before bootstrapping is done
    at getCLIOptionsFromBinding (node:internal/options:20:32)
    at getOptionValue (node:internal/options:45:19)
    at node:internal/bootstrap/node:433:29
```

PR-URL: #46533
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
danielleadams pushed a commit that referenced this pull request Apr 11, 2023
#45888 took the environment
creation code out of the scope covered by the v8::TryCatch
that we use to print early failures during environment creation.
So e.g. when adding something that would fail in node.js, we get

```
node:internal/options:554: Uncaught Error: Should not query options before bootstrapping is done
```

This patch restores that by adding another v8::TryCatch for it:

```
node:internal/options:20
    ({ options: optionsMap } = getCLIOptions());
                               ^

Error: Should not query options before bootstrapping is done
    at getCLIOptionsFromBinding (node:internal/options:20:32)
    at getOptionValue (node:internal/options:45:19)
    at node:internal/bootstrap/node:433:29
```

PR-URL: #46533
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants