deno
deno copied to clipboard
[help] Can't use it locally: `Error! Failed to complete request to /api/hello: Error: socket hang up`
Hi,
I'm trying to use deno as a runtime but it seems that I'm missing something in my setup.
My project
project
|__web
api
|__hello.ts
.vercel.json
hello.ts
export default () => new Response(`Hello, from Deno v${Deno.version.deno}!`);
vercel.json
{
"version": 2,
"functions": {
"api/**/*.[jt]s": {"runtime": "[email protected]"}
}
}
Vercel
I created a project in Vercel, linked it to my Git repository and defined web
as my root directory. Next, inside my project I ran vercel link
.
On my side
Deno v1.18.1
is installed, vercel CLI v23.1.2
is installed and NodeJS v16.13.0
is installed.
When I run vercel dev
, everything's good.
> Ready! Available at http://localhost:3000
But then when I go http://localhost:3000/api/hello
, I got:
502: BAD_GATEWAY
Code: NO_RESPONSE_FROM_FUNCTION
ID: dev1::dev1::tk09g-1643464806192-eb798a5b7597
and from the terminal
Error! Failed to complete request to /api/hello: Error: socket hang up
I tried on two computers (one using WSL2, one using macOS), result is the same.
The thing is that when I deploy on Vercel, the API is working: https://numbered-tech.vercel.app/api/hello.
What I'm missing?
Thanks
Same thing happening to me
the problem may cause by using Router from Oak. I tried to deploy both with Router implemented and without and the error only occurs on the Router implemented version.
I have exactly the same problem with a similar simple example
export default async () => new Response('pong');
Did you find a solution or workaround to make it work ? I don't know how to debug or understand the error...
Deno version : 1.23.1 Vercel : 27.2.0 vercel-deno 1.1.0
You can replace dev-server.ts
found in the following directories with the patched one in #102:
- macOS:
~/Library/Caches/com.vercel.cli/dev/builders/node_modules/vercel-deno
- Windows:
%APPDATA%\Roaming\npm\node_modules\vercel\node_modules\vercel-deno
Note these are not exact location (and I may be wrong).