-
Notifications
You must be signed in to change notification settings - Fork 555
Open
Description
Hey! π
In the following repo, https://github.com/mrbbot/windows-workerd-keep-alive-repro, making a request to a workerd instance that has been restarted on the same port using workerd's fetch() fails with Internal Server Error on Windows.
// index.mjs
// (see reproduction repo for full implementation and required files)
// Start user worker and proxy worker on random ports
const user1 = await spawnWorkerd("user.capnp", "0", { MESSAGE: "one" });
const proxy = await spawnWorkerd("proxy.capnp", "0");
// Send request to user worker through proxy worker
const res1 = await fetch(proxy.url, { headers: { Target: user1.url.href } });
console.log({ res1: await res1.text() }); // "one"
// Restart user worker on same port
await user1.kill();
const user2 = await spawnWorkerd("user.capnp", user1.url.port, { MESSAGE: "two" });
// Send request to new user worker through proxy worker
const res2 = await fetch(proxy.url, { headers: { Target: user1.url.href } });
console.log({ res2: await res2.text() }); // Internal Server Error, expected "two"
// Send another request to new user worker through proxy worker, now succeeds
const res3 = await fetch(proxy.url, { headers: { Target: user1.url.href } });
console.log({ res3: await res3.text() }); // "two"
await user2.kill();
await proxy.kill();PS C:\...> node index.mjs
{ res1: 'one' }
workerd/jsg/util.c++:283: info: exception = kj/async-io-win32.c++:372: disconnected: WSARecv(): #10054 An existing connection was forcibly closed by the remote host.
stack: 7ff633aad880 7ff633aa8b2f 7ff633aa764f 7ff633aa7497 7ff633e6d9fb 7ff633e6fd28 0 0 0 0 0
workerd/io/worker.c++:1842: info: uncaught exception; source = Uncaught (in promise); exception = Error: Network connection lost.
workerd/io/io-context.c++:394: info: uncaught exception; exception = workerd/jsg/_virtual_includes/jsg\workerd/jsg/value.h:1334: failed: jsg.Error: Network connection lost.
stack: 0 7ff633abb3ec 0 0
workerd/server/server.c++:2838: error: Uncaught exception: workerd/jsg/_virtual_includes/jsg\workerd/jsg/value.h:1334: failed: remote.jsg.Error: Network connection lost.
stack: 0 7ff633abb3ec 0 0 0 0 7ff633939475 7ff633e74934 7ff633e76250 7ff633e77020 0
{ res2: 'Internal Server Error' }
{ res3: 'two' }
This feels like workerd is keeping some socket to the shutdown user1 worker alive. Trying to fetch() on it makes workerd realise it's closed, so subsequent requests use a new socket.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels