-
Notifications
You must be signed in to change notification settings - Fork 335
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
Use service name as service worker script name #190
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If providing a filename is really the right approach, this seems like the best way to do it.
But I have to wonder about this:
This means if an error is thrown, it's difficult to identify which script threw from inspecting the stack trace.
If there's only one script, why is it difficult to identify?
Is the problem really that separate services are not distinguished from each other? If so, would an alternative option be to bake the service name into the script's display name? That could happen automatically and would benefit everyone.
If that solves the problem for miniflare, and miniflare is then able to apply source mapping to map locations back to their original input source code, then do we still need to add this filename option? I just feel like no one would ever bother specifying it when writing a worker by hand, and tool-generated configs don't really need it if they are applying source mapping on top anyway.
That's a good point.
Yep, this is the problem. Using However, for users that are just using |
3386aa7
to
f455aba
Compare
Ok, I've switched to using the service name as the script name. This is sufficient for Miniflare to distinguish scripts. If users want IDE click-to-location in stack traces, they can set the service name to their filename. 👍 This needs a small internal change too, so I'll make the PR for that now. |
LGTM but let's also have @kentonv review. |
f455aba
to
23eed29
Compare
23eed29
to
8d97864
Compare
@mrbbot ... I left a comment on the internal repo also but the CI run for this is fairly old. Can I ask you to rebase this and the internal repo so we can get a fresh CI run before we merge this. |
Sure! I'm away from my laptop for the next couple days, but will do this when I get back. 👍 |
8d97864
to
3e868d5
Compare
3e868d5
to
c081fdd
Compare
c081fdd
to
77d8204
Compare
cloudflare/workerd#190 changed the script name for service workers to their service name. This change updates Miniflare's heuristics for locating source maps to work with this. It also adds some tests to ensure source mapping is working correctly for the different ways of specifying a script.
cloudflare/workerd#190 changed the script name for service workers to their service name. This change updates Miniflare's heuristics for locating source maps to work with this. It also adds some tests to ensure source mapping is working correctly for the different ways of specifying a script.
cloudflare/workerd#190 changed the script name for service workers to their service name. This change updates Miniflare's heuristics for locating source maps to work with this. It also adds some tests to ensure source mapping is working correctly for the different ways of specifying a script.
cloudflare/workerd#190 changed the script name for service workers to their service name. This change updates Miniflare's heuristics for locating source maps to work with this. It also adds some tests to ensure source mapping is working correctly for the different ways of specifying a script.
cloudflare/workerd#190 changed the script name for service workers to their service name. This change updates Miniflare's heuristics for locating source maps to work with this. It also adds some tests to ensure source mapping is working correctly for the different ways of specifying a script.
cloudflare/workerd#190 changed the script name for service workers to their service name. This change updates Miniflare's heuristics for locating source maps to work with this. It also adds some tests to ensure source mapping is working correctly for the different ways of specifying a script.
cloudflare/workerd#190 changed the script name for service workers to their service name. This change updates Miniflare's heuristics for locating source maps to work with this. It also adds some tests to ensure source mapping is working correctly for the different ways of specifying a script.
cloudflare/workerd#190 changed the script name for service workers to their service name. This change updates Miniflare's heuristics for locating source maps to work with this. It also adds some tests to ensure source mapping is working correctly for the different ways of specifying a script.
cloudflare/workerd#190 changed the script name for service workers to their service name. This change updates Miniflare's heuristics for locating source maps to work with this. It also adds some tests to ensure source mapping is working correctly for the different ways of specifying a script.
Hey! 👋 Currently, when multiple nanoservices are configured with service worker scripts, they'll all use
worker.js
as their script origin. This means if an error is thrown, it's difficult to identify which script threw from inspecting the stack trace. We hit this issue in Miniflare, when attempting to locate source maps for service workers: https://github.com/cloudflare/miniflare/blob/5ecaae2b482feb583d8eeca2310785ea4d68165c/packages/tre/src/plugins/core/prettyerror.ts#L37-L41.This PR adds a new
name
option for configuring the script origin of service worker scripts. Rather than makingserviceWorkerScript
a:group
withname
, I've added a newserviceWorker
union member to maintain text-format compatibility.