-
Notifications
You must be signed in to change notification settings - Fork 215
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
Wrapped errors from sendMessage should include the original error name, stacktrace #210
Comments
This could be useful for debugging, but adds complexity and overhead to the implementation. Most users probably don't need this functionality. Therefore we'll close this bug. |
If we just copy over two additional properties that every Error has,
I'd actually argue the opposite extreme: Wanting to see the stack traces of errors is not a niche use case, but rather something 100% of the users of the polyfill would want. |
To implement this, we would need to special-case errors and add the stack here: webextension-polyfill/src/browser-polyfill.js Line 413 in 5f7a845
Then at the other side, we would have to reconstruct the (typed) error object at webextension-polyfill/src/browser-polyfill.js Line 457 in 5f7a845
In terms of code, it is not very difficult, but nonetheless it's more than nothing.
I'm sympathic to the idea of stack traces (I first-hand experience the pain of some bugs in missing/incorrect stack traces in Firefox during some unit tests), but I still maintain that it's mainly a development feature, and not something that can or should be relied upon for control flow in the extension ( But if rejected messages are expected to be rare, then the overhead of supporting stack traces are not as bad as I thought. I may consider re-opening the feature request (and review+accept a pull request), if @rpl agrees to. |
@Rob--W sure, I'm also ok with re-opening this and marking it as "contrib: welcome". |
I'll happily send up a PR for this. |
Stack traces are needed. @lguychard are you actively working on this? |
@lguychard any news? Thanks! |
+1 for the idea of converting error objects with a I'm contributing to an extension where rejections are shown as If this change would be welcome, I could be open to contributing it. |
It might be useful to use |
Errors returned by
onMessage
listeners are currently converted to JSON:webextension-polyfill/src/browser-polyfill.js
Lines 410 to 423 in 5f7a845
At present, only the
message
property of the original error is sent in the response. In the case where the rejected value is anError
instance, it would be nice to include other structured clone serializable properties from the original error, such asname
andstacktrace
.The text was updated successfully, but these errors were encountered: