vercel-community / rust

🦀 Rust runtime for ▲ Vercel Serverless Functions
https://rust-runtime.vercel.app
MIT License
845 stars 49 forks source link

Route merging leads to 502 error on `/api/main` #106

Closed arctic-hen7 closed 1 year ago

arctic-hen7 commented 1 year ago

Using the route merging feature, hits to API endpoints that don't exist return 404 errors, as expected, but hitting /api/main, at least when using vercel dev, leads to a 502 error when it doesn't exist, with the following console output:

thread 'main' panicked at 'internal error: entered unreachable code', api/api/main.rs:10:1
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
TypeError: Object prototype may only be an Object or null: undefined
    at Function.setPrototypeOf (<anonymous>)
    at new LambdaError (/home/arctic-hen7/.nvm/versions/node/v19.3.0/lib/node_modules/vercel/dist/index.js:8983:16)                                  
    at Lambda.<anonymous> (/home/arctic-hen7/.nvm/versions/node/v19.3.0/lib/node_modules/vercel/dist/index.js:9116:27)                                  
    at Generator.next (<anonymous>)
    at fulfilled (/home/arctic-hen7/.nvm/versions/node/v19.3.0/lib/node_modules/vercel/dist/index.js:9030:58

For me, this can be replicated with a minimal route merging configuration as in the readme. Note that line 10 refers to the #[bundled_api] macro. Unfortunately running RUST_BACKTRACE=1 vercel dev doesn't seem to pass the environment variable through for me, so I'm not sure how exactly to get a backtrace on this error locally.

ecklf commented 1 year ago

Will look into it. api/main should definitely 404 when merging as it just serves as entrypoint for the other handlers.

Unfortunately running RUST_BACKTRACE=1 vercel dev doesn't seem to pass the environment variable through for me, so I'm not sure how exactly to get a backtrace on this error locally.

You many also need to pass VERCEL_BUILDER_DEBUG=true to get a verbose cargo output.

manglemix commented 5 months ago

I am still facing this issue in the exact same manner