@wix/wix-code-diagnostics-plugin 1.1.6 → 1.1.7

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/README.md CHANGED
@@ -42,20 +42,23 @@ best-effort and never fails the CLI run.
42
42
 
43
43
  ## Runtime errors stream (`wix dev` only)
44
44
 
45
- On `cli:setup` with `cmd === 'dev'` the plugin also starts a local SSE server so
46
- the editor can show runtime errors from the running app:
45
+ On `cli:setup` with `cmd === 'dev'` the plugin also starts a local WebSocket
46
+ server so the editor can show runtime errors from the running app:
47
47
 
48
48
  | | |
49
49
  |---|---|
50
- | Endpoint | `GET http://127.0.0.1:52415/runtime-errors/stream` |
50
+ | Endpoint | `ws://127.0.0.1:52415/runtime-errors` |
51
51
  | Port | `52415` — fixed, like the CLI dev server's `52401`. `52402` is taken by the codegen agent |
52
- | Bind | Loopback only (`127.0.0.1`). Remote editors reach it through the sandbox's port proxy, never directly |
53
- | Event | `event: runtime-error`, `id: <occurrence id>`, `data: <json>` |
54
- | Payload | `{ id, name, message, file, line, column, stack, timestamp }` |
55
- | Replay | Ring buffer of the last 100 errors, replayed on connect; `Last-Event-ID` honored |
56
- | Heartbeat | `: ping` comment every ~25s |
57
- | Slow clients | A connection whose unflushed buffer reaches 1 MB is dropped, so a stalled reader cannot grow the dev process's memory |
58
- | Origins | `editor.wix.com`, `manage.wix.com`, `*.editor.wix.com`, `*.wix-code.com`. An `Origin` outside that list gets `403`; a request with no `Origin` is served without CORS headers |
52
+ | Bind | Loopback only (`127.0.0.1`). Remote editors reach it through the remote-machine dispatcher, never directly |
53
+ | Through the dispatcher | `wss://<editor-host>/remote-machine/studio-proxy/projects/<projectId>/ports/52415/runtime-errors`. The dispatcher forwards the **full** original path, so the server strips `/remote-machine/{proxy,studio-proxy}/projects/<id>/ports/<port>` before matching |
54
+ | Why WebSocket | The dispatcher buffers whole HTTP response bodies, so SSE (or any HTTP streaming) never reaches the editor. WebSocket upgrades are streamed through it frame by frame |
55
+ | Messages | JSON text frames: `{ "type": "runtime-error", "error": { id, name, message, file, line, column, stack, timestamp } }` and `{ "type": "ping" }` |
56
+ | Replay | Ring buffer of the last 100 errors, replayed on connect. `?after=<id>` replays only what came after that error; an unknown id (buffer rolled over) replays everything |
57
+ | Heartbeat | `{ "type": "ping" }` every ~25s. Application-level on purpose: browsers cannot observe protocol pings, and the editor needs to tell a live socket from a dead one |
58
+ | Status probe | A plain `GET` on the same path answers `200 { transport, path, bufferedErrors, connectedClients }` — handy for checking the proxy route from a browser tab |
59
+ | Slow clients | A socket whose unsent bytes reach 1 MB is terminated, so a stalled editor tab cannot grow the dev process's memory |
60
+ | Shutdown | When `wix dev` exits the process ends and the editor sees an abnormal close (`1006`); treat it like any dropped socket and reconnect with `?after=`. The programmatic `close()` sends `1001` (going away) and cuts a peer that does not answer within 1 s |
61
+ | Origins | `editor.wix.com`, `manage.wix.com`, `*.editor.wix.com`, `*.wix-code.com`. An `Origin` outside that list gets `403` on the upgrade and on the probe; a request with no `Origin` is served |
59
62
  | Origin override | `WIX_CODE_RUNTIME_ERRORS_ALLOWED_ORIGINS` replaces the list entirely — comma-separated. A hostname (`editor.wix.com`) matches on any scheme and port; a full origin (`http://localhost:3000`) matches **exactly**, that scheme and that port only; `*.editor.wix.com` matches any subdomain. An entry that is neither (`localhost:3000`, with a port but no scheme) is ambiguous, so it is dropped with a warning rather than widened. Set this to run a local editor against the stream |
60
63
  | Port clash | A second `wix dev` in the same sandbox cannot have `52415`. The stream moves to an ephemeral port and says so in the CLI output — the editor only looks at `52415`, so that run's errors do not reach it |
61
64
 
@@ -67,3 +70,7 @@ broadcast.
67
70
  Runtime errors are ephemeral by design: no orchestrator, no persistence, and the
68
71
  buffer dies with the dev server. The stream part is active on every `wix dev`
69
72
  run, independent of the two diagnostics env vars above.
73
+
74
+ `ws` is bundled into `dist/index.mjs`, so the published package still has no
75
+ runtime dependencies. Its optional native accelerators (`bufferutil`,
76
+ `utf-8-validate`) are left external and simply absent.
@@ -1,7 +1,15 @@
1
1
  export declare const RUNTIME_ERRORS_PORT = 52415;
2
- export declare const RUNTIME_ERRORS_PATH = "/runtime-errors/stream";
2
+ export declare const RUNTIME_ERRORS_PATH = "/runtime-errors";
3
+ /**
4
+ * Prefix the remote-machine dispatcher leaves on the request path when the editor reaches the
5
+ * sandbox through `https://<editor-host>/remote-machine/{proxy,studio-proxy}/projects/<projectId>/ports/<port>/…`.
6
+ * The dispatcher forwards the full original path, and the sandbox agent strips only its own
7
+ * `/dispatcher/<port>` prefix, so the plugin has to drop this one itself.
8
+ */
9
+ export declare const REMOTE_MACHINE_PROXY_PREFIX: RegExp;
10
+ export declare const REPLAY_AFTER_PARAM = "after";
3
11
  export declare const HEARTBEAT_INTERVAL_MS = 25000;
4
- export declare const RECONNECT_DELAY_MS = 2000;
12
+ export declare const CLOSE_GRACE_MS = 1000;
5
13
  export declare const RUNTIME_ERRORS_BUFFER_SIZE = 100;
6
14
  export declare const DEDUP_WINDOW_MS = 1000;
7
15
  export declare const MAX_ERRORS_PER_WINDOW = 50;
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,mBAAmB,QAAQ,CAAC;AAEzC,eAAO,MAAM,mBAAmB,2BAA2B,CAAC;AAE5D,eAAO,MAAM,qBAAqB,QAAS,CAAC;AAE5C,eAAO,MAAM,kBAAkB,OAAQ,CAAC;AAExC,eAAO,MAAM,0BAA0B,MAAM,CAAC;AAE9C,eAAO,MAAM,eAAe,OAAQ,CAAC;AAErC,eAAO,MAAM,qBAAqB,KAAK,CAAC;AAExC,eAAO,MAAM,cAAc,QAAS,CAAC;AAErC,eAAO,MAAM,wBAAwB,MAAM,CAAC;AAE5C,eAAO,MAAM,mBAAmB,4CAA4C,CAAC;AAE7E,eAAO,MAAM,wBAAwB;;;CAG3B,CAAC;AAEX,eAAO,MAAM,mBAAmB,cAAc,CAAC;AAE/C,eAAO,MAAM,uBAAuB,UAAY,CAAC"}
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,mBAAmB,QAAQ,CAAC;AAEzC,eAAO,MAAM,mBAAmB,oBAAoB,CAAC;AAErD;;;;;GAKG;AACH,eAAO,MAAM,2BAA2B,QAC0C,CAAC;AAEnF,eAAO,MAAM,kBAAkB,UAAU,CAAC;AAE1C,eAAO,MAAM,qBAAqB,QAAS,CAAC;AAE5C,eAAO,MAAM,cAAc,OAAQ,CAAC;AAEpC,eAAO,MAAM,0BAA0B,MAAM,CAAC;AAE9C,eAAO,MAAM,eAAe,OAAQ,CAAC;AAErC,eAAO,MAAM,qBAAqB,KAAK,CAAC;AAExC,eAAO,MAAM,cAAc,QAAS,CAAC;AAErC,eAAO,MAAM,wBAAwB,MAAM,CAAC;AAE5C,eAAO,MAAM,mBAAmB,4CAA4C,CAAC;AAE7E,eAAO,MAAM,wBAAwB;;;CAG3B,CAAC;AAEX,eAAO,MAAM,mBAAmB,cAAc,CAAC;AAE/C,eAAO,MAAM,uBAAuB,UAAY,CAAC"}
package/dist/index.d.ts CHANGED
@@ -7,5 +7,7 @@ export { startRuntimeErrorsServer } from './runtimeErrorsServer';
7
7
  export type { RuntimeErrorsServer, RuntimeErrorsServerOptions } from './runtimeErrorsServer';
8
8
  export { serializeRuntimeError, createRuntimeErrorLimiter } from './runtimeError';
9
9
  export type { SerializedRuntimeError } from './runtimeError';
10
- export { RUNTIME_ERRORS_PORT, RUNTIME_ERRORS_HOST, RUNTIME_ERRORS_PATH } from './constants';
10
+ export type { RuntimeErrorsMessage } from './protocol';
11
+ export { parseRequestPath } from './requestPath';
12
+ export { RUNTIME_ERRORS_PORT, RUNTIME_ERRORS_HOST, RUNTIME_ERRORS_PATH, REPLAY_AFTER_PARAM, REMOTE_MACHINE_PROXY_PREFIX, } from './constants';
11
13
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,UAAU,CAAC;AACpD,YAAY,EAAE,+BAA+B,EAAE,MAAM,UAAU,CAAC;AAChE,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC5E,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AACjE,YAAY,EAAE,mBAAmB,EAAE,0BAA0B,EAAE,MAAM,uBAAuB,CAAC;AAC7F,OAAO,EAAE,qBAAqB,EAAE,yBAAyB,EAAE,MAAM,gBAAgB,CAAC;AAClF,YAAY,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAC7D,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,UAAU,CAAC;AACpD,YAAY,EAAE,+BAA+B,EAAE,MAAM,UAAU,CAAC;AAChE,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC5E,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AACjE,YAAY,EAAE,mBAAmB,EAAE,0BAA0B,EAAE,MAAM,uBAAuB,CAAC;AAC7F,OAAO,EAAE,qBAAqB,EAAE,yBAAyB,EAAE,MAAM,gBAAgB,CAAC;AAClF,YAAY,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAC7D,YAAY,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EACL,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,EACnB,kBAAkB,EAClB,2BAA2B,GAC5B,MAAM,aAAa,CAAC"}