@timber-js/app 0.2.0-alpha.234 → 0.2.0-alpha.236
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/dist/_chunks/{actions-CYjRMpZI.js → actions-Top9GftB.js} +3 -3
- package/dist/_chunks/{actions-CYjRMpZI.js.map → actions-Top9GftB.js.map} +1 -1
- package/dist/_chunks/{cache-api-BZJNt01a.js → cache-api-Bo8c7XVF.js} +6 -6
- package/dist/_chunks/{cache-api-BZJNt01a.js.map → cache-api-Bo8c7XVF.js.map} +1 -1
- package/dist/_chunks/{chains-D-RRc7CM.js → chains-BsGKkMTK.js} +2 -2
- package/dist/_chunks/{chains-D-RRc7CM.js.map → chains-BsGKkMTK.js.map} +1 -1
- package/dist/_chunks/chains-DHmoKxkO.js +1 -0
- package/dist/_chunks/{classify-_W0RWa5w.js → classify-cmE0Gins.js} +2 -2
- package/dist/_chunks/{classify-_W0RWa5w.js.map → classify-cmE0Gins.js.map} +1 -1
- package/dist/_chunks/{cli-check-BAKOSTkg.js → cli-check-BwiahbTC.js} +5 -5
- package/dist/_chunks/{cli-check-BAKOSTkg.js.map → cli-check-BwiahbTC.js.map} +1 -1
- package/dist/_chunks/{cli-context-BPdyA7Fp.js → cli-context-BbwVqarO.js} +1 -1
- package/dist/_chunks/{cli-context-CwTKMjVe.js → cli-context-DZh5v0yd.js} +2 -2
- package/dist/_chunks/{cli-context-CwTKMjVe.js.map → cli-context-DZh5v0yd.js.map} +1 -1
- package/dist/_chunks/{cli-schema-sync-CAllbqRB.js → cli-schema-sync-B2ldclRO.js} +3 -3
- package/dist/_chunks/{cli-schema-sync-CAllbqRB.js.map → cli-schema-sync-B2ldclRO.js.map} +1 -1
- package/dist/_chunks/{cli-schema-sync-y_8ijmzO.js → cli-schema-sync-Brw7kTmm.js} +1 -1
- package/dist/_chunks/{client-dep-entries-C9hv-3k9.js → client-dep-entries-C1nMlLKV.js} +2 -2
- package/dist/_chunks/{client-dep-entries-C9hv-3k9.js.map → client-dep-entries-C1nMlLKV.js.map} +1 -1
- package/dist/_chunks/{cloudflare-_2fhxQE8.js → cloudflare-Dk5Hqo-O.js} +3 -3
- package/dist/_chunks/{cloudflare-_2fhxQE8.js.map → cloudflare-Dk5Hqo-O.js.map} +1 -1
- package/dist/_chunks/{convention-lint-D54k6uUM.js → convention-lint-CLpuzY5h.js} +3 -3
- package/dist/_chunks/{convention-lint-D54k6uUM.js.map → convention-lint-CLpuzY5h.js.map} +1 -1
- package/dist/_chunks/dev-server-BGGGhHXx.js +1 -0
- package/dist/_chunks/{dev-server-Rq659RR1.js → dev-server-lrdpD7Ws.js} +122 -6
- package/dist/_chunks/dev-server-lrdpD7Ws.js.map +1 -0
- package/dist/_chunks/{dev-span-_NzMX-au.js → dev-span-RsVeYYc_.js} +5 -2
- package/dist/_chunks/dev-span-RsVeYYc_.js.map +1 -0
- package/dist/_chunks/{error-boundary-Cf1m-Ywk.js → error-boundary-Bh-egWUI.js} +6 -6
- package/dist/_chunks/{error-boundary-Cf1m-Ywk.js.map → error-boundary-Bh-egWUI.js.map} +1 -1
- package/dist/_chunks/{flight-source-node-BGanuoSS.js → flight-source-node-BO_xD9jC.js} +2 -2
- package/dist/_chunks/{flight-source-node-BGanuoSS.js.map → flight-source-node-BO_xD9jC.js.map} +1 -1
- package/dist/_chunks/{href-BtspoNc9.js → href-8l5VD23D.js} +2 -2
- package/dist/_chunks/{href-BtspoNc9.js.map → href-8l5VD23D.js.map} +1 -1
- package/dist/_chunks/{json-lossy-check-BXM45k8p.js → json-lossy-check-D47R9Fp5.js} +2 -2
- package/dist/_chunks/{json-lossy-check-BXM45k8p.js.map → json-lossy-check-D47R9Fp5.js.map} +1 -1
- package/dist/_chunks/{live-graph-C7-yA8W9.js → live-graph-ChuFfmLi.js} +4 -4
- package/dist/_chunks/{live-graph-C7-yA8W9.js.map → live-graph-ChuFfmLi.js.map} +1 -1
- package/dist/_chunks/{logger-YtMSKfft.js → logger-DDLtp5e-.js} +16 -1
- package/dist/_chunks/logger-DDLtp5e-.js.map +1 -0
- package/dist/_chunks/navigation-root-Cvb7P1ud.js.map +1 -1
- package/dist/_chunks/{node-response-D3hXWb8y.js → node-response-DNNnKnoS.js} +2 -2
- package/dist/_chunks/{node-response-D3hXWb8y.js.map → node-response-DNNnKnoS.js.map} +1 -1
- package/dist/_chunks/{plugin-context-FCkaNLUB.js → plugin-context-BtaQcMuh.js} +2 -2
- package/dist/_chunks/{plugin-context-FCkaNLUB.js.map → plugin-context-BtaQcMuh.js.map} +1 -1
- package/dist/_chunks/{plugin-context-BfSRKJfz.js → plugin-context-I1dvGccO.js} +1 -1
- package/dist/_chunks/{poison-scan-CRSP06Es.js → poison-scan-CJ9QfJWb.js} +2 -2
- package/dist/_chunks/{poison-scan-CRSP06Es.js.map → poison-scan-CJ9QfJWb.js.map} +1 -1
- package/dist/_chunks/{scanner-BNQ4qnLX.js → scanner-CrB_h6FA.js} +5 -5
- package/dist/_chunks/{scanner-BNQ4qnLX.js.map → scanner-CrB_h6FA.js.map} +1 -1
- package/dist/_chunks/{sizeof-Cmx6Fs-Y.js → sizeof-DVhEVN_y.js} +2 -2
- package/dist/_chunks/{sizeof-Cmx6Fs-Y.js.map → sizeof-DVhEVN_y.js.map} +1 -1
- package/dist/_chunks/{walkers-D_QHR_nf.js → walkers-BUvpsb2Q.js} +3 -3
- package/dist/_chunks/{walkers-D_QHR_nf.js.map → walkers-BUvpsb2Q.js.map} +1 -1
- package/dist/adapters/cloudflare-dev.js +1 -1
- package/dist/adapters/cloudflare-kv-cache.js +2 -2
- package/dist/adapters/cloudflare.js +1 -1
- package/dist/adapters/nitro.js +1 -1
- package/dist/analyze/crawl-entry.js +4 -4
- package/dist/analyze/graph-command.js +5 -5
- package/dist/cache/index.js +2 -2
- package/dist/cache/stores/memory.js +1 -1
- package/dist/cli.js +6 -6
- package/dist/client/dev-pill/index.d.ts +2 -1
- package/dist/client/dev-pill/index.d.ts.map +1 -1
- package/dist/client/dev-pill/store.d.ts +0 -18
- package/dist/client/dev-pill/store.d.ts.map +1 -1
- package/dist/client/dev-pill/view.d.ts.map +1 -1
- package/dist/client/error-boundary.js +1 -1
- package/dist/client/index.js +4 -4
- package/dist/client/internal.js +3 -3
- package/dist/cookies/index.js +1 -1
- package/dist/dev-tools/await-span.d.ts +12 -1
- package/dist/dev-tools/await-span.d.ts.map +1 -1
- package/dist/dev-tools/instrumentation.d.ts.map +1 -1
- package/dist/dev-tools/logger.d.ts +8 -2
- package/dist/dev-tools/logger.d.ts.map +1 -1
- package/dist/dev-tools/span-sink.d.ts +9 -1
- package/dist/dev-tools/span-sink.d.ts.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +183 -40
- package/dist/index.js.map +1 -1
- package/dist/native/rsc/_react/chunks/{react-server-dom-webpack-server.node.development-hQ_odxIB.js → react-server-dom-webpack-server.node.development-CAttMzVD.js} +2 -2
- package/dist/native/rsc/_react/flight-client.js +2 -2
- package/dist/native/rsc/_react/flight-server.js +1 -1
- package/dist/native/rsc/_react/flight-static.js +1 -1
- package/dist/native/rsc/adapters/cloudflare-kv-cache.js +1 -1
- package/dist/native/rsc/adapters/cloudflare.js +2 -2
- package/dist/native/rsc/cache/cache-api.js +3 -3
- package/dist/native/rsc/cache/index.js +3 -3
- package/dist/native/rsc/cache/timber-cache.js +2 -2
- package/dist/native/rsc/cdn/index.js +1 -1
- package/dist/native/rsc/client/use-cookie.js +1 -1
- package/dist/native/rsc/dev-tools/404-page.js +1 -1
- package/dist/native/rsc/dev-tools/await-span.js +10 -7
- package/dist/native/rsc/dev-tools/await-span.js.map +1 -1
- package/dist/native/rsc/dev-tools/error-page.js +2 -2
- package/dist/native/rsc/dev-tools/instrumentation.js +38 -3
- package/dist/native/rsc/dev-tools/instrumentation.js.map +1 -1
- package/dist/native/rsc/dev-tools/logger.js +123 -80
- package/dist/native/rsc/dev-tools/logger.js.map +1 -1
- package/dist/native/rsc/dev-tools/span-sink.js +1 -0
- package/dist/native/rsc/dev-tools/span-sink.js.map +1 -1
- package/dist/native/rsc/dev-tools/terminal.js +1 -1
- package/dist/native/rsc/manifest.json +2 -2
- package/dist/native/rsc/params/index.js +1 -1
- package/dist/native/rsc/routing/collision-probe.js +1 -1
- package/dist/native/rsc/routing/interception.js +1 -1
- package/dist/native/rsc/search-params/define.js +2 -2
- package/dist/native/rsc/server/access-gate.js +1 -1
- package/dist/native/rsc/server/action-client.js +2 -2
- package/dist/native/rsc/server/action-handler.js +8 -8
- package/dist/native/rsc/server/actions.js +3 -3
- package/dist/native/rsc/server/children-interception.js +1 -1
- package/dist/native/rsc/server/deny-boundary.js +1 -1
- package/dist/native/rsc/server/deny-renderer.js +10 -10
- package/dist/native/rsc/server/fallback-error.js +1 -1
- package/dist/native/rsc/server/flight-injector-core.js +2 -2
- package/dist/native/rsc/server/flight-source-node.js +2 -2
- package/dist/native/rsc/server/index.js +4 -4
- package/dist/native/rsc/server/interception-gates.js +2 -2
- package/dist/native/rsc/server/internal.js +15 -15
- package/dist/native/rsc/server/logger.js +2 -2
- package/dist/native/rsc/server/metadata-route-links.js +1 -1
- package/dist/native/rsc/server/node-body-response.js +1 -1
- package/dist/native/rsc/server/param-coercion.js +1 -1
- package/dist/native/rsc/server/pipeline-helpers.js +10 -10
- package/dist/native/rsc/server/pipeline-interception.js +4 -4
- package/dist/native/rsc/server/pipeline-metadata-route.js +10 -10
- package/dist/native/rsc/server/pipeline-outcome.js +4 -4
- package/dist/native/rsc/server/pipeline-phases.js +11 -11
- package/dist/native/rsc/server/pipeline.js +10 -10
- package/dist/native/rsc/server/prebuilt/capture-render.js +1 -1
- package/dist/native/rsc/server/prebuilt/dev-store.js +1 -1
- package/dist/native/rsc/server/prebuilt/overlay.js +3 -3
- package/dist/native/rsc/server/prebuilt-builder.js +8 -8
- package/dist/native/rsc/server/prebuilt-runtime.js +15 -15
- package/dist/native/rsc/server/primitives.js +2 -2
- package/dist/native/rsc/server/publish-params.js +1 -1
- package/dist/native/rsc/server/request-context.js +1 -1
- package/dist/native/rsc/server/route-element-builder.js +7 -7
- package/dist/native/rsc/server/route-element-helpers.js +1 -1
- package/dist/native/rsc/server/route-handler.js +1 -1
- package/dist/native/rsc/server/rsc-entry/action-dispatcher.js +1 -1
- package/dist/native/rsc/server/rsc-entry/action-middleware-runner.js +1 -1
- package/dist/native/rsc/server/rsc-entry/api-handler.js +1 -1
- package/dist/native/rsc/server/rsc-entry/deny-fallback.js +6 -6
- package/dist/native/rsc/server/rsc-entry/error-renderer.js +7 -7
- package/dist/native/rsc/server/rsc-entry/helpers.js +1 -1
- package/dist/native/rsc/server/rsc-entry/render-route.js +4 -4
- package/dist/native/rsc/server/rsc-entry/revalidate-renderer.js +7 -7
- package/dist/native/rsc/server/rsc-entry/rsc-payload.js +3 -3
- package/dist/native/rsc/server/rsc-entry/rsc-stream.js +6 -6
- package/dist/native/rsc/server/rsc-entry/ssr-renderer.js +10 -10
- package/dist/native/rsc/server/rsc-error-envelope.js +1 -1
- package/dist/native/rsc/server/sitemap-handler.js +1 -1
- package/dist/native/rsc/server/skippable-prefix.js +2 -2
- package/dist/native/rsc/server/slot-interception.js +1 -1
- package/dist/native/rsc/server/slot-resolver.js +11 -11
- package/dist/native/rsc/server/static-generator.js +2 -2
- package/dist/native/rsc/server/traced-access.js +1 -1
- package/dist/native/rsc/server/tracing.js +10 -0
- package/dist/native/rsc/server/tracing.js.map +1 -1
- package/dist/native/rsc/shared/dev-span.js +11 -4
- package/dist/native/rsc/shared/dev-span.js.map +1 -1
- package/dist/native/rsc/shared/href.js +1 -1
- package/dist/native/rsc/shared/span-waterfall.js +90 -0
- package/dist/native/rsc/shared/span-waterfall.js.map +1 -0
- package/dist/native/ssr/adapters/cloudflare-kv-cache.js +1 -1
- package/dist/native/ssr/adapters/cloudflare.js +2 -2
- package/dist/native/ssr/cache/cache-api.js +3 -3
- package/dist/native/ssr/cache/guarded-read.js +1 -1
- package/dist/native/ssr/cache/index.js +3 -3
- package/dist/native/ssr/cache/timber-cache.js +3 -3
- package/dist/native/ssr/cdn/index.js +1 -1
- package/dist/native/ssr/client/error-boundary.js +1 -1
- package/dist/native/ssr/client/index.js +5 -5
- package/dist/native/ssr/client/link.js +5 -5
- package/dist/native/ssr/client/navigation-commit.js +2 -2
- package/dist/native/ssr/client/nuqs-adapter.js +2 -2
- package/dist/native/ssr/client/params-context.js +1 -1
- package/dist/native/ssr/client/router-skew.js +1 -1
- package/dist/native/ssr/client/rsc-fetch.js +2 -2
- package/dist/native/ssr/client/use-pending-navigation.js +1 -1
- package/dist/native/ssr/client/use-search-params.js +2 -2
- package/dist/native/ssr/client/use-segment-params.js +1 -1
- package/dist/native/ssr/client/use-selected-layout-segment.js +1 -1
- package/dist/native/ssr/dev-tools/await-span.js +10 -7
- package/dist/native/ssr/dev-tools/await-span.js.map +1 -1
- package/dist/native/ssr/dev-tools/instrumentation.js +38 -3
- package/dist/native/ssr/dev-tools/instrumentation.js.map +1 -1
- package/dist/native/ssr/dev-tools/logger.js +123 -80
- package/dist/native/ssr/dev-tools/logger.js.map +1 -1
- package/dist/native/ssr/dev-tools/span-sink.js +1 -0
- package/dist/native/ssr/dev-tools/span-sink.js.map +1 -1
- package/dist/native/ssr/manifest.json +1 -0
- package/dist/native/ssr/params/index.js +1 -1
- package/dist/native/ssr/search-params/define.js +2 -2
- package/dist/native/ssr/server/access-gate.js +1 -1
- package/dist/native/ssr/server/action-client.js +2 -2
- package/dist/native/ssr/server/actions.js +3 -3
- package/dist/native/ssr/server/deny-boundary.js +2 -2
- package/dist/native/ssr/server/flight-injector-core.js +1 -1
- package/dist/native/ssr/server/flight-source-node.js +2 -2
- package/dist/native/ssr/server/index.js +4 -4
- package/dist/native/ssr/server/internal.js +12 -12
- package/dist/native/ssr/server/logger.js +2 -2
- package/dist/native/ssr/server/node-body-response.js +1 -1
- package/dist/native/ssr/server/node-stream-transforms.js +2 -2
- package/dist/native/ssr/server/param-coercion.js +3 -3
- package/dist/native/ssr/server/pipeline-helpers.js +7 -7
- package/dist/native/ssr/server/pipeline-interception.js +4 -4
- package/dist/native/ssr/server/pipeline-metadata-route.js +10 -10
- package/dist/native/ssr/server/pipeline-outcome.js +4 -4
- package/dist/native/ssr/server/pipeline-phases.js +10 -10
- package/dist/native/ssr/server/pipeline.js +10 -10
- package/dist/native/ssr/server/prebuilt/capture-render.js +2 -2
- package/dist/native/ssr/server/prebuilt/dev-store.js +1 -1
- package/dist/native/ssr/server/prebuilt/overlay.js +4 -4
- package/dist/native/ssr/server/prebuilt-runtime.js +14 -14
- package/dist/native/ssr/server/primitives.js +2 -2
- package/dist/native/ssr/server/request-context.js +2 -2
- package/dist/native/ssr/server/route-handler.js +1 -1
- package/dist/native/ssr/server/rsc-error-envelope.js +1 -1
- package/dist/native/ssr/server/ssr-form-state.js +2 -2
- package/dist/native/ssr/server/ssr-wrappers.js +1 -1
- package/dist/native/ssr/server/traced-access.js +1 -1
- package/dist/native/ssr/server/tracing.js +10 -0
- package/dist/native/ssr/server/tracing.js.map +1 -1
- package/dist/native/ssr/shared/dev-span.js +11 -4
- package/dist/native/ssr/shared/dev-span.js.map +1 -1
- package/dist/native/ssr/shared/href.js +1 -1
- package/dist/native/ssr/shared/span-waterfall.js +90 -0
- package/dist/native/ssr/shared/span-waterfall.js.map +1 -0
- package/dist/plugins/dev-await.d.ts +3 -0
- package/dist/plugins/dev-await.d.ts.map +1 -1
- package/dist/plugins/dev-precompile.d.ts +84 -0
- package/dist/plugins/dev-precompile.d.ts.map +1 -0
- package/dist/plugins/dev-server.d.ts.map +1 -1
- package/dist/plugins/entries.d.ts.map +1 -1
- package/dist/plugins/native-runtime.d.ts +2 -2
- package/dist/plugins/native-runtime.d.ts.map +1 -1
- package/dist/plugins/plugin-rsc-package.d.ts +35 -0
- package/dist/plugins/plugin-rsc-package.d.ts.map +1 -0
- package/dist/plugins/virtual-ids.d.ts +16 -0
- package/dist/plugins/virtual-ids.d.ts.map +1 -0
- package/dist/routes/index.js +1 -1
- package/dist/routing/index.js +3 -3
- package/dist/search-params/index.js +2 -2
- package/dist/server/index.js +2 -2
- package/dist/server/internal.js +14 -14
- package/dist/server/tracing.d.ts.map +1 -1
- package/dist/shared/dev-span.d.ts +21 -3
- package/dist/shared/dev-span.d.ts.map +1 -1
- package/dist/shared/span-waterfall.d.ts +88 -0
- package/dist/shared/span-waterfall.d.ts.map +1 -0
- package/package.json +3 -3
- package/src/client/dev-pill/index.ts +5 -2
- package/src/client/dev-pill/store.ts +5 -64
- package/src/client/dev-pill/view.ts +175 -53
- package/src/dev-tools/await-span.ts +32 -13
- package/src/dev-tools/instrumentation.ts +44 -6
- package/src/dev-tools/logger.ts +230 -155
- package/src/dev-tools/span-sink.ts +34 -3
- package/src/index.ts +24 -21
- package/src/plugins/dev-await.ts +61 -3
- package/src/plugins/dev-precompile.ts +168 -0
- package/src/plugins/dev-server.ts +16 -3
- package/src/plugins/entries.ts +1 -11
- package/src/plugins/native-runtime.ts +4 -3
- package/src/plugins/plugin-rsc-package.ts +81 -0
- package/src/plugins/virtual-ids.ts +15 -0
- package/src/server/tracing.ts +29 -0
- package/src/shared/dev-span.ts +29 -6
- package/src/shared/span-waterfall.ts +227 -0
- package/dist/_chunks/chains-KblEfYzm.js +0 -1
- package/dist/_chunks/dev-server-L8biS7Az.js +0 -1
- package/dist/_chunks/dev-server-Rq659RR1.js.map +0 -1
- package/dist/_chunks/dev-span-_NzMX-au.js.map +0 -1
- package/dist/_chunks/logger-YtMSKfft.js.map +0 -1
package/src/shared/dev-span.ts
CHANGED
|
@@ -5,7 +5,10 @@
|
|
|
5
5
|
* Isomorphic: no server, client, or build-time imports.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
/**
|
|
8
|
+
/**
|
|
9
|
+
* HMR event that carries finished spans to the browser: a
|
|
10
|
+
* `DevSpanPayload[]` of one trace, in the order the spans ended.
|
|
11
|
+
*/
|
|
9
12
|
export const DEV_SPAN_EVENT = 'timber:span';
|
|
10
13
|
|
|
11
14
|
/** HMR event a tab sends to ask for a trace's spans that ended before it connected. */
|
|
@@ -33,6 +36,14 @@ export const DEV_AWAIT_KEY = Symbol.for('timber.dev.await');
|
|
|
33
36
|
/** Span name for one awaited call in app server code. */
|
|
34
37
|
export const AWAIT_SPAN_NAME = 'timber.await';
|
|
35
38
|
|
|
39
|
+
/**
|
|
40
|
+
* Set on an await span that waited on work started elsewhere: a promise
|
|
41
|
+
* another await already took (React's `cache()`), or one made before the
|
|
42
|
+
* await began (`const p = load(); … await p`). The work's own spans nest
|
|
43
|
+
* where it started, so the wait adds no new information when they exist.
|
|
44
|
+
*/
|
|
45
|
+
export const AWAIT_WAIT_ATTRIBUTE = 'timber.await_wait';
|
|
46
|
+
|
|
36
47
|
/**
|
|
37
48
|
* Await spans shorter than this are dropped before they reach the terminal
|
|
38
49
|
* tree or the pill: `await params` and other awaits of settled values would
|
|
@@ -40,6 +51,16 @@ export const AWAIT_SPAN_NAME = 'timber.await';
|
|
|
40
51
|
*/
|
|
41
52
|
export const AWAIT_SPAN_MIN_MS = 1;
|
|
42
53
|
|
|
54
|
+
/** Span name for one dev-instrumented `fetch()`, ended when headers arrive. */
|
|
55
|
+
export const FETCH_SPAN_NAME = 'timber.fetch';
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Span name for reading a fetched response's body (`.text()`, `.json()`,
|
|
59
|
+
* …), a child of the fetch span. The fetch span ends at headers, so without
|
|
60
|
+
* it a slow body read showed only as the `await res.text()` that waited on it.
|
|
61
|
+
*/
|
|
62
|
+
export const FETCH_BODY_SPAN_NAME = 'timber.fetch.body';
|
|
63
|
+
|
|
43
64
|
/** Root span of every pipeline request. */
|
|
44
65
|
export const ROOT_SPAN_NAME = 'http.server.request';
|
|
45
66
|
|
|
@@ -67,8 +88,8 @@ export const DEV_SPAN_ATTRIBUTES = [
|
|
|
67
88
|
'timber.await_label',
|
|
68
89
|
/** `path/relative/to/root.ts:line` of the await. */
|
|
69
90
|
'timber.await_location',
|
|
70
|
-
/**
|
|
71
|
-
'timber.
|
|
91
|
+
/** See `AWAIT_WAIT_ATTRIBUTE`. */
|
|
92
|
+
'timber.await_wait',
|
|
72
93
|
] as const;
|
|
73
94
|
|
|
74
95
|
export type DevSpanAttribute = (typeof DEV_SPAN_ATTRIBUTES)[number];
|
|
@@ -172,12 +193,14 @@ export function devSpanLabel(name: string, attrs: SpanAttributes): { label: stri
|
|
|
172
193
|
return { label: `page ${slotPrefix(attrs)}${String(route)}`, env: 'rsc' };
|
|
173
194
|
}
|
|
174
195
|
case AWAIT_SPAN_NAME:
|
|
175
|
-
//
|
|
196
|
+
// A wait on work started elsewhere — no new work under it.
|
|
176
197
|
return {
|
|
177
|
-
label: `await ${String(attrs['timber.await_label'] ?? '')}${attrs[
|
|
198
|
+
label: `await ${String(attrs['timber.await_label'] ?? '')}${attrs[AWAIT_WAIT_ATTRIBUTE] === true ? ' (wait)' : ''}`,
|
|
178
199
|
env: 'await',
|
|
179
200
|
};
|
|
180
|
-
case
|
|
201
|
+
case FETCH_BODY_SPAN_NAME:
|
|
202
|
+
return { label: 'response body', env: 'fetch' };
|
|
203
|
+
case FETCH_SPAN_NAME: {
|
|
181
204
|
const fetchMethod = attrs['http.request.method'] ?? 'GET';
|
|
182
205
|
const fetchUrl = attrs['http.url'] ?? '';
|
|
183
206
|
return { label: `fetch ${String(fetchMethod)} ${String(fetchUrl)}`, env: 'fetch' };
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A trace's spans as rows to read: the dev request pill's waterfall and the
|
|
3
|
+
* terminal tree.
|
|
4
|
+
*
|
|
5
|
+
* Pure: spans in, rows out. Built to be read, not to mirror the span tree.
|
|
6
|
+
* Waits whose work other rows already show can be hidden, and pass-through
|
|
7
|
+
* wrappers can fold into the row they wrap. One implementation for both
|
|
8
|
+
* surfaces, so the pill and the terminal never disagree about which awaits
|
|
9
|
+
* are noise. See design/50-dev-request-pill.md §"Reading the awaits view".
|
|
10
|
+
*
|
|
11
|
+
* Isomorphic: no server, client, or build-time imports.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import {
|
|
15
|
+
AWAIT_SPAN_NAME,
|
|
16
|
+
AWAIT_WAIT_ATTRIBUTE,
|
|
17
|
+
FETCH_BODY_SPAN_NAME,
|
|
18
|
+
FETCH_SPAN_NAME,
|
|
19
|
+
} from './dev-span.ts';
|
|
20
|
+
|
|
21
|
+
/** The I/O: awaits, fetches, and fetched bodies being read. */
|
|
22
|
+
const IO_SPANS = new Set([AWAIT_SPAN_NAME, FETCH_SPAN_NAME, FETCH_BODY_SPAN_NAME]);
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* A wait is explained when spans outside its own ancestry cover this much
|
|
26
|
+
* of its time. It waited on the work those spans show.
|
|
27
|
+
*/
|
|
28
|
+
const WAIT_COVERAGE = 0.8;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* An await folds into its only child when the child takes this much of the
|
|
32
|
+
* await's time. A wrapper that adds no time of its own adds no information.
|
|
33
|
+
*/
|
|
34
|
+
const FOLD_COVERAGE = 0.9;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* What the rules read from a span. The pill's `DevSpanPayload` and the
|
|
38
|
+
* terminal's projection of an OTEL `ReadableSpan` both satisfy it.
|
|
39
|
+
*/
|
|
40
|
+
export interface WaterfallSpan {
|
|
41
|
+
spanId: string;
|
|
42
|
+
/** Absent, or not among the spans, for a top-level span. */
|
|
43
|
+
parentSpanId?: string;
|
|
44
|
+
name: string;
|
|
45
|
+
startMs: number;
|
|
46
|
+
endMs: number;
|
|
47
|
+
attributes: Readonly<Record<string, unknown>>;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export interface WaterfallOptions<T extends WaterfallSpan = WaterfallSpan> {
|
|
51
|
+
/** Keep only the I/O, awaits and fetches (the pill's awaits view). */
|
|
52
|
+
ioOnly?: boolean;
|
|
53
|
+
/** Spans to leave out, with their shown children in their place. */
|
|
54
|
+
skip?: (span: T) => boolean;
|
|
55
|
+
/** Leave out waits other spans explain. */
|
|
56
|
+
hideWaits?: boolean;
|
|
57
|
+
/** Fold pass-through awaits into the row they wrap. */
|
|
58
|
+
fold?: boolean;
|
|
59
|
+
/** Rows the user unfolded, by the outer span's ID. */
|
|
60
|
+
expanded?: ReadonlySet<string>;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export interface WaterfallRow<T extends WaterfallSpan> {
|
|
64
|
+
/** The row's outermost span: its position, depth and location. */
|
|
65
|
+
span: T;
|
|
66
|
+
/** Spans folded into this row, outermost first. Empty when nothing folded. */
|
|
67
|
+
folded: T[];
|
|
68
|
+
/** An explained wait: shown only on request, and dimmed. */
|
|
69
|
+
wait: boolean;
|
|
70
|
+
depth: number;
|
|
71
|
+
/** Milliseconds from the trace's start. */
|
|
72
|
+
offsetMs: number;
|
|
73
|
+
durationMs: number;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export interface Waterfall<T extends WaterfallSpan> {
|
|
77
|
+
rows: WaterfallRow<T>[];
|
|
78
|
+
/** Explained waits left out of `rows`. */
|
|
79
|
+
hiddenWaits: number;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const duration = (s: WaterfallSpan) => s.endMs - s.startMs;
|
|
83
|
+
|
|
84
|
+
/** Total length of the union of [start, end) intervals. */
|
|
85
|
+
function unionLength(intervals: Array<[number, number]>): number {
|
|
86
|
+
let total = 0;
|
|
87
|
+
let reach = -Infinity;
|
|
88
|
+
for (const [start, end] of intervals.sort((a, b) => a[0] - b[0])) {
|
|
89
|
+
if (end <= reach) continue;
|
|
90
|
+
total += end - Math.max(start, reach);
|
|
91
|
+
reach = end;
|
|
92
|
+
}
|
|
93
|
+
return total;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Await spans that waited on work other spans already show, by ID.
|
|
98
|
+
*
|
|
99
|
+
* A wait (`timber.await_wait`) with no children waited on a promise made
|
|
100
|
+
* elsewhere. When that work is traced (an app function's awaits, a fetch),
|
|
101
|
+
* it runs at the same time outside the wait's own ancestry, so it covers the
|
|
102
|
+
* wait. When it isn't (`const p = pool.query(); … await p`, the driver
|
|
103
|
+
* being in node_modules), nothing covers it, and the wait is the only row
|
|
104
|
+
* that shows the time. Then it counts as work.
|
|
105
|
+
*
|
|
106
|
+
* A wait with children started work after all (a getter that returns a new
|
|
107
|
+
* promise), so it counts as work too.
|
|
108
|
+
*/
|
|
109
|
+
export function explainedWaits(spans: readonly WaterfallSpan[]): Set<string> {
|
|
110
|
+
const byId = new Map(spans.map((s) => [s.spanId, s]));
|
|
111
|
+
const parents = new Set(spans.map((s) => s.parentSpanId));
|
|
112
|
+
const isCandidate = (s: WaterfallSpan) =>
|
|
113
|
+
s.attributes[AWAIT_WAIT_ATTRIBUTE] === true && !parents.has(s.spanId);
|
|
114
|
+
const work = spans.filter((s) => IO_SPANS.has(s.name) && !isCandidate(s));
|
|
115
|
+
const explained = new Set<string>();
|
|
116
|
+
for (const wait of spans) {
|
|
117
|
+
if (!isCandidate(wait) || duration(wait) <= 0) continue;
|
|
118
|
+
const ancestors = new Set<string>();
|
|
119
|
+
for (let p = wait.parentSpanId; p && !ancestors.has(p); p = byId.get(p)?.parentSpanId) {
|
|
120
|
+
ancestors.add(p);
|
|
121
|
+
}
|
|
122
|
+
const covering: Array<[number, number]> = [];
|
|
123
|
+
for (const s of work) {
|
|
124
|
+
if (ancestors.has(s.spanId)) continue;
|
|
125
|
+
const start = Math.max(s.startMs, wait.startMs);
|
|
126
|
+
const end = Math.min(s.endMs, wait.endMs);
|
|
127
|
+
if (end > start) covering.push([start, end]);
|
|
128
|
+
}
|
|
129
|
+
if (unionLength(covering) >= WAIT_COVERAGE * duration(wait)) explained.add(wait.spanId);
|
|
130
|
+
}
|
|
131
|
+
return explained;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Spans in tree order (parent before children, siblings by start). The time
|
|
136
|
+
* axis starts at the trace's first span.
|
|
137
|
+
*
|
|
138
|
+
* - `ioOnly` keeps only awaits and fetches, each nested under its nearest
|
|
139
|
+
* kept ancestor, so hiding framework phases leaves no gaps in the
|
|
140
|
+
* indentation.
|
|
141
|
+
* - `hideWaits` leaves out explained waits, with their children (they have
|
|
142
|
+
* none: a wait with children isn't explained).
|
|
143
|
+
* - `skip` leaves out the spans it matches, like `ioOnly` does.
|
|
144
|
+
* - `fold`: an await whose only shown child takes nearly all its time folds
|
|
145
|
+
* into one row with that child (unless the child is a wait), repeatedly,
|
|
146
|
+
* so `loadShow → def.load → fetch` is one row. So does a framework span
|
|
147
|
+
* into an only child that is an await (`proxy.ts → await next()`), which
|
|
148
|
+
* only arises when framework spans are shown. A fetch folds nothing. A
|
|
149
|
+
* row in `expanded`
|
|
150
|
+
* doesn't fold.
|
|
151
|
+
*/
|
|
152
|
+
export function buildWaterfall<T extends WaterfallSpan>(
|
|
153
|
+
spans: readonly T[],
|
|
154
|
+
{
|
|
155
|
+
ioOnly = false,
|
|
156
|
+
skip,
|
|
157
|
+
hideWaits = false,
|
|
158
|
+
fold = false,
|
|
159
|
+
expanded = new Set<string>(),
|
|
160
|
+
}: WaterfallOptions<T> = {}
|
|
161
|
+
): Waterfall<T> {
|
|
162
|
+
if (spans.length === 0) return { rows: [], hiddenWaits: 0 };
|
|
163
|
+
const ids = new Set(spans.map((s) => s.spanId));
|
|
164
|
+
const children = new Map<string | undefined, T[]>();
|
|
165
|
+
for (const span of spans) {
|
|
166
|
+
// A span whose parent isn't here (the root still open, or a parent
|
|
167
|
+
// outside this trace's spans) sits at the top level.
|
|
168
|
+
const parent = span.parentSpanId && ids.has(span.parentSpanId) ? span.parentSpanId : undefined;
|
|
169
|
+
const siblings = children.get(parent) ?? [];
|
|
170
|
+
siblings.push(span);
|
|
171
|
+
children.set(parent, siblings);
|
|
172
|
+
}
|
|
173
|
+
for (const siblings of children.values()) siblings.sort((a, b) => a.startMs - b.startMs);
|
|
174
|
+
|
|
175
|
+
const waits = explainedWaits(spans);
|
|
176
|
+
const kept = (s: T) => (!ioOnly || IO_SPANS.has(s.name)) && !skip?.(s);
|
|
177
|
+
const hidden = (s: T) => hideWaits && waits.has(s.spanId);
|
|
178
|
+
|
|
179
|
+
/** Shown children, with an unkept child's shown descendants in its place. */
|
|
180
|
+
const visibleChildren = (parent: string | undefined): T[] =>
|
|
181
|
+
(children.get(parent) ?? []).flatMap((s) =>
|
|
182
|
+
hidden(s) ? [] : kept(s) ? [s] : visibleChildren(s.spanId)
|
|
183
|
+
);
|
|
184
|
+
|
|
185
|
+
const origin = Math.min(...spans.map((s) => s.startMs));
|
|
186
|
+
const rows: WaterfallRow<T>[] = [];
|
|
187
|
+
const emit = (span: T, depth: number) => {
|
|
188
|
+
const folded: T[] = [];
|
|
189
|
+
let tail = span;
|
|
190
|
+
let kids = visibleChildren(tail.spanId);
|
|
191
|
+
// A wait never folds: shown on request, it must appear as its own,
|
|
192
|
+
// dimmed row, not vanish into its parent. A child that outlives its
|
|
193
|
+
// parent (a fetch raced against a timeout) never folds either: the row
|
|
194
|
+
// draws the parent's interval, which would drop the rest of the child's
|
|
195
|
+
// time. Codex review on #1288.
|
|
196
|
+
const foldable = (kid: T | undefined): kid is T =>
|
|
197
|
+
kid !== undefined &&
|
|
198
|
+
!waits.has(kid.spanId) &&
|
|
199
|
+
(tail.name === AWAIT_SPAN_NAME ||
|
|
200
|
+
(kid.name === AWAIT_SPAN_NAME && !IO_SPANS.has(tail.name))) &&
|
|
201
|
+
kid.startMs >= tail.startMs &&
|
|
202
|
+
kid.endMs <= tail.endMs &&
|
|
203
|
+
duration(kid) >= FOLD_COVERAGE * duration(tail);
|
|
204
|
+
if (fold && !expanded.has(span.spanId)) {
|
|
205
|
+
for (
|
|
206
|
+
let only = kids.length === 1 ? kids[0] : undefined;
|
|
207
|
+
foldable(only);
|
|
208
|
+
only = kids.length === 1 ? kids[0] : undefined
|
|
209
|
+
) {
|
|
210
|
+
tail = only;
|
|
211
|
+
folded.push(tail);
|
|
212
|
+
kids = visibleChildren(tail.spanId);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
rows.push({
|
|
216
|
+
span,
|
|
217
|
+
folded,
|
|
218
|
+
wait: waits.has(span.spanId),
|
|
219
|
+
depth,
|
|
220
|
+
offsetMs: span.startMs - origin,
|
|
221
|
+
durationMs: duration(span),
|
|
222
|
+
});
|
|
223
|
+
for (const kid of kids) emit(kid, depth + 1);
|
|
224
|
+
};
|
|
225
|
+
for (const span of visibleChildren(undefined)) emit(span, 0);
|
|
226
|
+
return { rows, hiddenWaits: hideWaits ? waits.size : 0 };
|
|
227
|
+
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { t as formatChains } from "./chains-D-RRc7CM.js";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { t as RESTART_EXIT_CODE } from "./dev-server-Rq659RR1.js";
|