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

Propage h5wasm errors to viewer #1570

Closed
axelboc opened this issue Feb 8, 2024 · 5 comments · Fixed by #1586
Closed

Propage h5wasm errors to viewer #1570

axelboc opened this issue Feb 8, 2024 · 5 comments · Fixed by #1586
Labels
bug Something isn't working

Comments

@axelboc
Copy link
Contributor

axelboc commented Feb 8, 2024

Describe the bug

When h5wasm throws an error internally, for instance when reading a compressed dataset without the appropriate plugin, the error appears in the console but is not propagated to the viewer.

For compressed datasets, if we didn't throw our own error when the required compression plugins aren't available, we might not even realise the problem, since the visualization would most likely continue to work. In other cases, like with this bug report that was encountered on myHDF5, the h5wasm error causes the viewer to throw another, completely unrelated error further down the line, which can be confusing.

To Reproduce

  1. Comment out one of the plugins in apps/demo/src/h5wasm/plugin-utils.ts (e.g. Zstandard) and silence the TS error.
  2. Comment out the line that throws the "plugin not supported" error in packages/h5wasm/src/h5wasm-api.ts (replace with early return).
  3. Start the demo and visit http://localhost:5173/h5wasm?url=https%3A%2F%2Fwww.silx.org%2Fpub%2Fh5web%2Ffilters.h5
  4. Select the dataset matching the compression plugin that you disabled (e.g. zstd).
  5. 👉 The Line visualization appears to work but there is an error in the browser console.

Expected behaviour

When h5wasm throws an error, this error should be propagated to the viewer and trigger the visualization area's error boundary.

@axelboc axelboc added the bug Something isn't working label Feb 8, 2024
@axelboc
Copy link
Contributor Author

axelboc commented Feb 9, 2024

Apparently, exception handling is disabled in Emscripten by default. So it might simply be a matter of compiling h5wasm with flag -fwasm-exceptions.

@bmaranville
Copy link
Contributor

By default, the HDF5 library error handler function prints to the error stream for every error. This is what is ending up in the users' console. That error handler function can be overridden, but it would require writing a new error handler function in C, and setting that as the default. There don't seem to be a lot of examples of custom error handler functions.

It's possible that the C++ API for for HDF5 has exception handling in it already - but migrating to that API from the C API would also be some work.

@bmaranville
Copy link
Contributor

There is a PR brewing for raising exceptions in h5wasm here: usnistgov/h5wasm#68
I still have to write some tests, but it seems to work as expected.

@axelboc
Copy link
Contributor Author

axelboc commented Feb 29, 2024

Fantastic!! Thanks for looking into this 💯

@bmaranville
Copy link
Contributor

Opt-in to throwing error handler is available new release https://github.com/usnistgov/h5wasm/releases/tag/v0.7.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
2 participants