Closed ItsWendell closed 7 months ago
Hi @ItsWendell , thanks for raising this issue. Good point, the fact that resvg
throw
s that error can clutter the logs quickly.
I don't think setting up global variable is the best approach here as resvg
is already doing that with this variable:
var initialized = false;
And so I believe there won't be any performance benefit either by checking this ourselves.
So I think a simple matching of the error message, and then skipping the console.error
would suffice:
https://github.com/kvnang/workers-og/commit/44e526f6eedb1fff6076c63c0c45aefb981a30e9
And also, actually throw
ing the error sounds like a good idea to me, so that's been implemented as well.
https://github.com/kvnang/workers-og/commit/3aac7691579cf584f8d8d229b191e0a1278eaa75
Anything else feel free to re-open this. Thanks!
Currently, when a worker already initialized the wasm modules, the initialization throws the error:
Error: Already initialized. The
initWasm()function can be used only once.
.This package already uses
try ... catch
around the initialization functions, and does aconsole.error
when this happens, even though this indicates that it's safe to continue using the module. I would love this error not to show up when this happens, since this clutters our logs.In my opinion, we should actually throw the error once it's not the
Already initialized
error, and prevent initializing twice.Suggested approach
try ... catch
to make the system aware of actual errors other thanAlready initialized
occurring and we can catch it with e.g. error tracking software.I'm willing to open a PR if this approach sounds good!