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

asyncLoad: fix empty error message #21889

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Kojoley
Copy link

@Kojoley Kojoley commented May 3, 2024

Before:

[UnhandledPromiseRejection: This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason "undefined".] {
  code: 'ERR_UNHANDLED_REJECTION'
}

After:

[Error: ENOENT: no such file or directory, open 'A:\path\to\foo.wasm'] {
  errno: -4058,
  code: 'ENOENT',
  syscall: 'open',
  path: 'A:\\path\\to\\foo.wasm'
}

Before:
```
[UnhandledPromiseRejection: This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason "undefined".] {
  code: 'ERR_UNHANDLED_REJECTION'
}
```

After:
```
[Error: ENOENT: no such file or directory, open 'A:\path\to\foo.wasm'] {
  errno: -4058,
  code: 'ENOENT',
  syscall: 'open',
  path: 'A:\\path\\to\\foo.wasm'
}
```
Copy link
Collaborator

@sbc100 sbc100 left a comment

Choose a reason for hiding this comment

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

Thanks!

if (onerror) {
onerror();
onerror(err);
Copy link
Member

Choose a reason for hiding this comment

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

I looked at the first few users of this and didn't see any that use the parameter - where did you see it used? Or was this for an out-of-tree usage?

Copy link
Collaborator

Choose a reason for hiding this comment

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

@Kojoley could you elaborate on what API you were using when you saw the difference above? How where you using it exactly?

Copy link
Author

@Kojoley Kojoley May 7, 2024

Choose a reason for hiding this comment

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

mkdir link_test
echo ; > link_test.cpp
emcc -fPIC -sSIDE_MODULE -Wall -g -c "link_test.cpp" -o "link_test.o"
emcc -fPIC -sSIDE_MODULE "link_test.o" -o "link_test/foo.wasm"

echo int main() { return 0; } > main.cpp
emcc -fPIC -sMAIN_MODULE -Wall -g -c "main.cpp" -o "main.o"
emcc -fPIC -sMAIN_MODULE "main.o" "link_test/foo.wasm" -o "link_test.js"

node link_test.js

Copy link
Member

Choose a reason for hiding this comment

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

Do you know where in that output it uses the parameter? Or is it hard to figure out? (I'd hope you can add console.log(new Error().stack) right where the parameter is received, to show the stack trace.)

Copy link
Author

Choose a reason for hiding this comment

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

I'm not the person that can comfortably debug that for you, sorry. I don't write Javascript nor have a clue about emscripten internals. It took me a while already to get to this point.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Thanks for the repro case. I think this change is good but I will do a little more investigation here before landing so I (we) fully understand what is going on here.

} else {
throw `Loading data file "${url}" failed.`;
throw err;
Copy link
Member

Choose a reason for hiding this comment

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

Perhaps it makes sense to keep the text here? The context could be nice. I'm not sure if there's a way to append more text to an existing Error object, though...

Copy link
Author

Choose a reason for hiding this comment

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

Look at the OP/commit message, readAsync already has the accurate error information, this does not add any additional information, quite an opposite, it has less information.

Copy link
Member

Choose a reason for hiding this comment

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

Interesting. So the text "Loading data file .. failed" was swallowed somewhere, I guess? Anyhow, sounds good that this improves things.

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

3 participants