cloudflare / cloudflare/workerd

🐛 Bug Report/Feature Request: improve fallback service error message on js code compilation errors

Open
#2,197 0 comments 0 reactions 1 assignee Claimed by @jasnell View on GitHub
Dominant language
C++
Stars
8.7k
Forks
739
Avg merge
2d 20h
Merged PRs (30d)
174

Description

The module fallback service given code that contains a syntax error returns an error response saying that the requested module could not be found, instead of clearly saying that a compilation error occurred, while using the service I encountered this causing me confusion and making me question if my code was failing to correctly fetch the module, so I think it would be great if this could be improved.
___

[minimal reproduction made by using miniflare](https://github.com/dario-piotrowicz/workerd-module-fallback-syntax-error-module-not-found-repro)

___

I think that the main issue is the fact that here on errors we simply only return a failed-to-fetch-module error:
https://github.com/cloudflare/workerd/blob/1a99c34134819f3ddca2a0672c613c1a6f7b8f8e/src/workerd/server/server.c%2B%2B#L2872-L2876

I'm guessing that in order to catch syntax errors (or any possible errors?) and surface them correctly to the user we should try-catch this piece of code?
https://github.com/cloudflare/workerd/blob/1a99c34134819f3ddca2a0672c613c1a6f7b8f8e/src/workerd/server/server.c%2B%2B#L2866

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.