@playfast/reform-remote-node 1.1.0 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/index.ts +10 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@playfast/reform-remote-node",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"description": "Node WebSocket server adapter for reform-remote — serves a reform scene's UI over the `ws` package, one isolated runtime per connection.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"effect",
|
package/src/index.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Server } from 'node:http'
|
|
2
|
-
import { Schema } from 'effect'
|
|
2
|
+
import { Option, Schema } from 'effect'
|
|
3
3
|
import { type RawData, WebSocketServer } from 'ws'
|
|
4
4
|
import type { AnyScene } from '@playfast/reform/internal'
|
|
5
5
|
import {
|
|
@@ -106,9 +106,15 @@ export const serveNodeWebSocket = (
|
|
|
106
106
|
await shared.dispose()
|
|
107
107
|
// `wss.close` waits for live sockets to drain.
|
|
108
108
|
wss.clients.forEach((client) => client.terminate())
|
|
109
|
-
await new Promise<void>((resolve, reject) =>
|
|
110
|
-
wss.close((error) => (error === undefined ? resolve() : reject(error)))
|
|
111
|
-
|
|
109
|
+
await new Promise<void>((resolve, reject) => {
|
|
110
|
+
wss.close((error) => (error === undefined ? resolve() : reject(error)))
|
|
111
|
+
// Bun's `ws` frees the port but never invokes that callback nor emits 'close',
|
|
112
|
+
// which would hang teardown forever. Both runtimes drop `address()` the moment
|
|
113
|
+
// the listener is gone, so that fact — not the signal — is what we settle on.
|
|
114
|
+
if (Option.isNone(Option.fromNullable(wss.address()))) {
|
|
115
|
+
resolve()
|
|
116
|
+
}
|
|
117
|
+
})
|
|
112
118
|
},
|
|
113
119
|
}
|
|
114
120
|
}
|