You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The following differences exist between the Workers implementation and Node.js:
174
174
175
175
- Trailer headers are not supported
176
-
- The `socket` attribute only contains the following properties: `encrypted`, `remoteFamily`, `remoteAddress`, `remotePort`, `localAddress`, `localPort`, and `destroy()` method
177
-
- The `socket` attribute does not extend from `net.Socket`
176
+
- The `socket` attribute **does not extend from `net.Socket`** and only contains the following properties: `encrypted`, `remoteFamily`, `remoteAddress`, `remotePort`, `localAddress`, `localPort`, and `destroy()` method
The `httpServerHandler` function integrates Node.js HTTP servers with the Cloudflare Workers request model. When a request arrives at your Worker, the handler automatically routes it to your Node.js server running on the specified port. This bridge allows you to use familiar Node.js server patterns while benefiting from the Workers runtime environment, including automatic scaling, edge deployment, and integration with other Cloudflare services.
199
198
200
199
:::note
201
-
Failing to call `close()` on an HTTP server may result in the server being leaked. To prevent this, call `close()` when you're done with the server, or use explicit resource management:
200
+
Failing to call `close()` on an HTTP server may result in the server persisting until the worker is destroyed. In most cases, this is not an issue since servers typically live for the lifetime of the worker. However, if you need to create multiple servers during a worker's lifetime or want explicit lifecycle control (such as in test scenarios), call `close()` when you're done with the server, or use explicit resource management:
202
201
203
202
```js
204
203
import { createServer } from'node:http';
@@ -243,24 +242,13 @@ An implementation of the Node.js [`http.ServerResponse`](https://nodejs.org/docs
243
242
244
243
The `ServerResponse` class represents the server-side response object that is passed to request handlers. It provides methods for writing response headers and body data, and extends the Node.js `Writable` stream class.
0 commit comments