mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-28 06:53:42 +08:00
The runtime fired every socket, server, request and response event from
the event loop with no store. Node runs them in the context of the
resource or request that produced them, so getStore() answered
undefined in listeners where Node answers the caller's store.
Handles now keep the context Node uses and the runtime enters it around
each dispatch:
- a socket the context of its creation (net.connect, tls.connect, an
http request's socket), for 'connect', 'data', 'end', 'close',
'error' and 'timeout';
- a server the contexts of its listen() call ('listening', 'connection',
listen errors) and its close() call ('close' and close callbacks when
no connection is open; a close that waits for the last connection
settles in that connection's dispatch, as in Node);
- socket write() callbacks and end() callbacks with 'finish' the
contexts of their calls;
- http server requests and responses, which are created in their
connection's dispatch, the server's listen() context, and client
requests and their responses the http.request() context, including a
keep-alive socket an agent hands to a later request.
An accepted net socket runs its own events with no store, as in Node;
the sockets of an HTTP or TLS server run in the server's listen()
context. Events and callbacks of other streams are unchanged.
The compiler is unchanged. Programs without net or http link the same
runtime code; net and http programs gain the capture and dispatch
helpers (about 1.7 KB of text in a net program, 2.2 KB in an http
server), and bench:runtime http-api is neutral.
Corpus 7119 and 7380.