Skip to content

Commit

Permalink
do not throw error if file is not a data loader
Browse files Browse the repository at this point in the history
  • Loading branch information
cinxmo committed Nov 3, 2023
1 parent ea807d0 commit 0fc3aa3
Showing 1 changed file with 0 additions and 1 deletion.
1 change: 0 additions & 1 deletion src/preview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ class Server {
send(req, filepath, {root: this.cacheRoot}).pipe(res);
return;
}
throw new HttpError("Not found", 404);

This comment has been minimized.

Copy link
@wiltsecarpenter

wiltsecarpenter Nov 3, 2023

Contributor

This is the error for when you request a _file/ Url that doesn't exist as a file or a loader, so I think we need this. What was the problem it was fixing?

This comment has been minimized.

Copy link
@mbostock

mbostock Nov 4, 2023

Member

I agree. This also looks necessary to me.

This comment has been minimized.

Copy link
@cinxmo

cinxmo Nov 4, 2023

Author Contributor

It already checks if the file exists on line 63:
https://github.com/observablehq/cli/blob/0fc3aa3a9d4b0cc0ae31b4b23f04b1cc0ce460e3/src/preview.ts#L62-L69

I think the issue is we don't have a good way to distinguish between a file that's supposed to be created via a data loader vs a regular ES module, at least in preview.

This comment has been minimized.

Copy link
@mbostock

mbostock Nov 4, 2023

Member

That code continues if the file doesn’t exist; it only throws an error if there was an error besides ENOENT.

} else {
if (normalize(pathname).startsWith("..")) throw new Error("Invalid path: " + pathname);
let path = join(this.root, pathname);
Expand Down

0 comments on commit 0fc3aa3

Please sign in to comment.