The Node 'upgrade' listener matched the raw request path without the normalization HTTP runs. A bad percent escape in a param segment threw URIError synchronously inside the listener, an uncaught exception that ends the process, and '//' silently matched a route HTTP refuses. Upgrades now normalize the path first: malformed escapes and repeated slashes get a 400, an unknown route a written 404 instead of a bare destroy, and any other throw in the listener a 500. app.upgrade (Deno/Bun/edge) closes 1008 'invalid request path' rather than 1011. On Deno the adapter's socket is still CONNECTING when an early 1008 is sent, and that close was a no-op that left the peer hanging; eventSocket now defers such a close to 'open'. Closes #104 Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
35 lines
903 B
TypeScript
35 lines
903 B
TypeScript
// Worker entry for the real workerd (Miniflare) integration test.
|
|
// Mirrors test/deno/ws.test.ts's graph so HTTP + WebSocket behavior is proven
|
|
// identically across runtimes. Run via `npm run test:edge` (see test/edge/run.ts).
|
|
import { createApp, Route, Get, Ws, ctx, Module } from '../../src/index';
|
|
import { edgeHandler } from '../../src/edge';
|
|
|
|
@Route('/rt')
|
|
class Rt {
|
|
@Get('/hello')
|
|
hello() {
|
|
return { ok: true };
|
|
}
|
|
|
|
@Ws('/echo')
|
|
echo(@ctx() { inbound }: any) {
|
|
return (async function* () {
|
|
for await (const msg of inbound) yield `echo:${msg}`;
|
|
})();
|
|
}
|
|
|
|
@Ws('/room/:name')
|
|
room(@ctx() { inbound }: any) {
|
|
return (async function* () {
|
|
for await (const msg of inbound) yield `room:${msg}`;
|
|
})();
|
|
}
|
|
}
|
|
|
|
@Module({ mountpoint: '/', controllers: [Rt] })
|
|
class M {}
|
|
|
|
const app = createApp({ modules: [M] });
|
|
|
|
export default { fetch: edgeHandler(app) };
|