Skip to content

Should modules really be 'null' if the HTTP status code is not-ok? #12657

Description

@jakearchibald

What is the issue with the HTML Standard?

https://html.spec.whatwg.org/multipage/webappapis.html#fetch-a-single-module-script:~:text=response%27s%20status%20is%20not%20an%20ok%20status%2C,-then%20set

Right now, entries in the module graph are set to null (meaning failure) if the status code is not-ok. Is this really the right pattern? Now that we have 'json' and 'text' imports, and maybe soon 'bytes', should we revisit this?

If you made an API request for /some/api/users/jakearchibalf and jakearchibalf didn't exist, the general pattern is to return a 404, but with valid JSON explaining the error. Hiding that valid JSON seems weird for a JSON import.

With 'text' and 'bytes' imports, it's less clear, as developers may not consider the occasional HTTP 500 resulting in a response.

Perhaps we need to extend the import syntax with something like:

import text from 'whatever' with { type: 'text', status: 'any' };

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions