-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
module: improve error message for invalid data URL #37701
Conversation
114e4c8
to
68fcf83
Compare
@nodejs/modules |
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.
Just my 2¢. Not sure that error code has been used for this purpose historically.
CC: @ljharb since this mentions MIME to user |
to clarify a bit, these should have been picked up and could have been generated in the past |
Seems fine to me, since anyone using a data URL is already familiar with MIMEs (this is ofc not true for almost every other specifier category). |
Ping @nodejs/modules for reviews. |
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.
Aside from my outstanding comments (non-blocking), everything else looks pretty good to me.
I will be digging around this part of codebase in a few days, so I will report back if I find issues.
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.
Perhaps Unsupported MIME "text/plain" loading "data:text/plain,export default 0".
Also it could be nice if we could support the parent context for tracing where it comes from eg if it were import('data:...')
in a module, it helps to know where the import expression is.
@guybedford Agreed, although I think this would deserve its own PR to align with other |
@aduh95 I do think it's important to move the "unsupported MIME" part to the beginning of the message though. This is because the data URL could be of any length, so that when scanning the error the user should be able to easily see the "unsupported MIME" part first. It also fixes that the current error isn't quite gramatically complete without a comma or colon or something type of break otherwise. Alternatively to make it gramatically correct:
|
I went to the last suggestion as it was the easiest to implement. I think you have a point regarding very long specifiers occulting the reason, maybe we can fix that in a similar way as proposed in #37852 (comment)? |
I believe the feature request outlined in #37581 is precisely the error property we need. |
Fixes: nodejs#37647 PR-URL: nodejs#37701 Reviewed-By: Derek Lewis <DerekNonGeneric@inf.is> Reviewed-By: Guy Bedford <guybedford@gmail.com>
f5ed39f
to
46062a0
Compare
Landed in 46062a0 |
Fixes: #37647
Changes the error message when importing module with an unknown/unsupported MIME type from:
to