Skip to content

Invalid imports should not crash the preview server #1179

Open
@mbostock

Description

@mbostock

This causes the preview server to render an error on load instead of just an invalid import:

import "npm:@observablehq/does-not-exist";

And if the code block is added to an existing page, the preview server crashes!

npm:@observablehq/does-not-exist → …/framework/src/npm.ts:224
    if (!response.ok) throw new Error(`unable to fetch: ${href}`);
                            ^

Error: unable to fetch: https://data.jsdelivr.com/v1/packages/npm/@observablehq/does-not-exist/resolved
    at <anonymous> (…/framework/src/npm.ts:224:29)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

We should catch such an error and let the import fail on the client instead.

(It’s desirable to crash the build, though, so you don’t accidentally deploy a broken site.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn’t working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions