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

Add error message for missing content-type header #2197

Merged
merged 3 commits into from Jun 27, 2020

Conversation

brandones
Copy link
Contributor

Currently, if the Content-Type header is missing from the response, the error that appears in the console is TypeError: Cannot read property 'match' of null. I'd like to preempt that error with a more helpful one, reusing the existing Error #4.

Copy link
Collaborator

@joeldenning joeldenning left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good, and I think it's worth the few extra bytes to help people diagnose issues loading modules. I've added one suggestion

src/extras/module-types.js Outdated Show resolved Hide resolved
@joeldenning
Copy link
Collaborator

If you could add a test for this, that would also be great, too. However, I won't block approval on it.

Co-authored-by: Joel Denning <joeldenning@gmail.com>
Copy link
Collaborator

@joeldenning joeldenning left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I'll plan on merging and publishing tomorrow.

@brandones
Copy link
Contributor Author

Sorry about the slow response. If you don't mind waiting, I could take a crack at writing a test tomorrow.

It looks like it should go in test/browser/core.js?

@joeldenning
Copy link
Collaborator

joeldenning commented Jun 24, 2020

It looks like it should go in test/browser/core.js?

Yes. Additionally, you'll need to configure the server to omit the content-type header from its response - see

systemjs/test/server.cjs

Lines 12 to 19 in d37f7ca

const mimes = {
'.html': 'text/html',
'.css': 'text/css',
'.js': 'application/javascript',
'.mjs': 'application/javascript',
'.json': 'application/json',
'.wasm': 'application/wasm'
};
as a starting point. Perhaps it would make sense to make an exception to those mime types for a specific fixture that you create for this test.

Copy link
Collaborator

@joeldenning joeldenning left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tests look good to me. I'll plan on merging and publishing this in the next day or so.

@joeldenning joeldenning merged commit 809e91f into systemjs:master Jun 27, 2020
@joeldenning
Copy link
Collaborator

Released in https://github.com/systemjs/systemjs/releases/tag/6.3.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants