@solidjs/web 2.0.0-rc.21 → 2.0.0-rc.23

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.
@@ -20,7 +20,15 @@ function rewriteTree(value, visit, withPath) {
20
20
  } catch (err) {
21
21
  if (err !== CYCLE) throw err;
22
22
  }
23
- return clone(value, visit, path, state.memo || (state.memo = new Map()));
23
+ const memo = state.memo || (state.memo = new Map());
24
+ const marks = {
25
+ at: new Map(),
26
+ stack: [],
27
+ changed: new Set(),
28
+ next: 0
29
+ };
30
+ mark(value, visit, path, memo, marks);
31
+ return clone(value, memo, marks.changed);
24
32
  }
25
33
  function shape(value) {
26
34
  return Array.isArray(value) ? 1 : Object.getPrototypeOf(value) === Object.prototype ? 2 : 0;
@@ -68,28 +76,73 @@ function cow(value, visit, path, depth, state) {
68
76
  if (ancestors !== undefined) ancestors.delete(value);
69
77
  return out;
70
78
  }
71
- function clone(value, visit, path, memo) {
72
- if (memo.has(value)) return memo.get(value);
79
+ function mark(value, visit, path, memo, m) {
80
+ const seen = m.at.get(value);
81
+ if (seen !== undefined) return seen;
82
+ if (memo.has(value)) return -1;
73
83
  const r = visit(value, path);
74
84
  if (r !== DESCEND) {
75
85
  memo.set(value, r);
76
- return r;
86
+ return -1;
77
87
  }
78
88
  const s = shape(value);
79
- if (s === 0) return value;
80
- const out = s === 1 ? value.slice() : {
89
+ if (s === 0) return -1;
90
+ const index = m.next++;
91
+ let low = index;
92
+ let changed = false;
93
+ let open = false;
94
+ const keys = s === 1 ? value : Object.keys(value);
95
+ for (let i = 0; i < keys.length; i++) {
96
+ const k = s === 1 ? i : keys[i];
97
+ const c = value[k];
98
+ if (c === null || typeof c !== "object") continue;
99
+ if (!open) {
100
+ open = true;
101
+ m.at.set(value, index);
102
+ m.stack.push(value);
103
+ }
104
+ const l = mark(c, visit, path === undefined ? undefined : s === 1 ? `${path}[${k}]` : `${path}.${k}`, memo, m);
105
+ if (l >= 0 && l < low) low = l;
106
+ if (memo.has(c) && memo.get(c) !== c || l === Infinity && m.changed.has(c)) changed = true;
107
+ }
108
+ if (!open) return -1;
109
+ if (low === index) {
110
+ m.at.set(value, Infinity);
111
+ if (m.stack[m.stack.length - 1] === value) {
112
+ m.stack.pop();
113
+ if (changed) m.changed.add(value);
114
+ return Infinity;
115
+ }
116
+ const members = m.stack.splice(m.stack.lastIndexOf(value));
117
+ if (!changed) for (const n of members) if (m.changed.has(n)) {
118
+ changed = true;
119
+ break;
120
+ }
121
+ for (const n of members) {
122
+ m.at.set(n, Infinity);
123
+ if (changed) m.changed.add(n);
124
+ }
125
+ return Infinity;
126
+ }
127
+ if (changed) m.changed.add(value);
128
+ return low;
129
+ }
130
+ function clone(value, memo, changed) {
131
+ if (memo.has(value)) return memo.get(value);
132
+ if (!changed.has(value)) return value;
133
+ const out = Array.isArray(value) ? value.slice() : {
81
134
  ...value
82
135
  };
83
136
  memo.set(value, out);
84
- if (s === 1) {
137
+ if (Array.isArray(value)) {
85
138
  for (let i = 0; i < value.length; i++) {
86
139
  const c = value[i];
87
- if (c !== null && typeof c === "object") out[i] = clone(c, visit, path === undefined ? undefined : `${path}[${i}]`, memo);
140
+ if (c !== null && typeof c === "object") out[i] = clone(c, memo, changed);
88
141
  }
89
142
  } else {
90
143
  for (const k of Object.keys(value)) {
91
144
  const c = value[k];
92
- if (c !== null && typeof c === "object") out[k] = clone(c, visit, path === undefined ? undefined : `${path}.${k}`, memo);
145
+ if (c !== null && typeof c === "object") out[k] = clone(c, memo, changed);
93
146
  }
94
147
  }
95
148
  return out;
@@ -255,7 +308,7 @@ function createKeyedSerializer(serialize, onError, onDone) {
255
308
  stream = serialize(key, value, {
256
309
  onError: onError && (err => {
257
310
  failed = true;
258
- onError(err);
311
+ onError(err, key);
259
312
  if (cancel) {
260
313
  cancel();
261
314
  settle();
@@ -1017,10 +1070,9 @@ function frameStream(makeCode, options) {
1017
1070
  };
1018
1071
  }
1019
1072
  function slotRange(occurrence) {
1020
- return {
1021
- t: `<!--slot:${occurrence}:start--><!--slot:${occurrence}:end-->`,
1073
+ return Object.assign(markup(`<!--slot:${occurrence}:start--><!--slot:${occurrence}:end-->`), {
1022
1074
  $slot: true
1023
- };
1075
+ });
1024
1076
  }
1025
1077
  function argBorderForm(value, needs) {
1026
1078
  return toBorderForm(noteTraces(value, needs));
@@ -1157,6 +1209,16 @@ function suppressedFill(render) {
1157
1209
  live.suppressed--;
1158
1210
  }
1159
1211
  }
1212
+ const SSR_NODE = Symbol.for("solid.ssrNode");
1213
+ const markup = (t, h, p) => h ? {
1214
+ t,
1215
+ h,
1216
+ p,
1217
+ $: SSR_NODE
1218
+ } : {
1219
+ t,
1220
+ $: SSR_NODE
1221
+ };
1160
1222
  let parked = null;
1161
1223
  let parkedIds = 0;
1162
1224
  const PARKED = /<!--sc-n:(\d+)-->/;
@@ -1167,9 +1229,7 @@ function park(render) {
1167
1229
  render,
1168
1230
  out: undefined
1169
1231
  });
1170
- return {
1171
- t: `<!--sc-n:${id}-->`
1172
- };
1232
+ return markup(`<!--sc-n:${id}-->`);
1173
1233
  }
1174
1234
  const runParked = (entry, owner) => entry.out || (entry.out = entry.render(owner));
1175
1235
  function placeParked(node, nested, owner) {
@@ -1187,22 +1247,14 @@ function expandParked(node, nested, owner) {
1187
1247
  if (!node.h) return splitParked(node.t, nested, owner) || node;
1188
1248
  const out = [];
1189
1249
  node.t.forEach((t, i) => {
1190
- out.push(splitParked(t, nested, owner) || {
1191
- t
1192
- });
1193
- if (i < node.h.length) out.push({
1194
- t: ["", ""],
1195
- h: [node.h[i]],
1196
- p: [node.p[i]]
1197
- });
1250
+ out.push(splitParked(t, nested, owner) || markup(t));
1251
+ if (i < node.h.length) out.push(markup(["", ""], [node.h[i]], [node.p[i]]));
1198
1252
  });
1199
1253
  return out;
1200
1254
  }
1201
1255
  function splitParked(t, nested, owner) {
1202
1256
  const parts = typeof t === "string" ? t.split(PARKED) : [t];
1203
- return parts.length > 1 ? parts.map((part, i) => i & 1 ? runParked(nested.get(+part), owner) : {
1204
- t: part
1205
- }) : undefined;
1257
+ return parts.length > 1 ? parts.map((part, i) => i & 1 ? runParked(nested.get(+part), owner) : markup(part)) : undefined;
1206
1258
  }
1207
1259
  function createDocumentSlotProps(clientProps, frameId) {
1208
1260
  const counts = Object.create(null);
@@ -1235,11 +1287,7 @@ function createDocumentSlotProps(clientProps, frameId) {
1235
1287
  const getters = new Map();
1236
1288
  const repeats = new Map();
1237
1289
  const range = (occurrence, content, tail) => {
1238
- const r = [{
1239
- t: `<!--slot:${occurrence}:start-->`
1240
- }, content, tail, {
1241
- t: `<!--slot:${occurrence}:end-->`
1242
- }];
1290
+ const r = [markup(`<!--slot:${occurrence}:start-->`), content, tail, markup(`<!--slot:${occurrence}:end-->`)];
1243
1291
  r.$slot = true;
1244
1292
  return r;
1245
1293
  };
@@ -1360,11 +1408,7 @@ function createDocumentSlotProps(clientProps, frameId) {
1360
1408
  resolved[key] = () => {
1361
1409
  if (region.locked) return [];
1362
1410
  region.used = true;
1363
- return [{
1364
- t: frameElementOpen(childId)
1365
- }, region.nested && region.nested.size ? placeParked(value, region.nested, getOwner()) : value, {
1366
- t: FRAME_ELEMENT_CLOSE
1367
- }];
1411
+ return [markup(frameElementOpen(childId)), region.nested && region.nested.size ? placeParked(value, region.nested, getOwner()) : value, markup(FRAME_ELEMENT_CLOSE)];
1368
1412
  };
1369
1413
  } else if (ssrAsyncValue && isAsyncValue(value)) {
1370
1414
  let readable = value;
@@ -1659,9 +1703,7 @@ function frameTransformDirectResult(value, {
1659
1703
  const address = frameAddress(id, args);
1660
1704
  const wrapped = props => {
1661
1705
  const siteId = documentSiteId(id);
1662
- return [{
1663
- t: frameElementOpen(siteId, address.slice(id.length + 1))
1664
- },
1706
+ return [markup(frameElementOpen(siteId, address.slice(id.length + 1))),
1665
1707
  serverOwned(() => {
1666
1708
  const page = sharedConfig.context;
1667
1709
  armDocumentLiveHoles(page);
@@ -1677,9 +1719,7 @@ function frameTransformDirectResult(value, {
1677
1719
  } finally {
1678
1720
  sharedConfig.context = page;
1679
1721
  }
1680
- }), {
1681
- t: FRAME_ELEMENT_CLOSE
1682
- }];
1722
+ }), markup(FRAME_ELEMENT_CLOSE)];
1683
1723
  };
1684
1724
  wrapped[SERVER_COMPONENT] = id;
1685
1725
  wrapped[SERVER_COMPONENT_SOURCE] = component;
@@ -1822,10 +1862,9 @@ function createSlotProps(sink, frame) {
1822
1862
  if (repeat) return repeat;
1823
1863
  if (sweeping && !live.scope) {
1824
1864
  live.gateHit = true;
1825
- return {
1826
- t: "",
1865
+ return Object.assign(markup(""), {
1827
1866
  $slot: true
1828
- };
1867
+ });
1829
1868
  }
1830
1869
  const raw = callArgs[0];
1831
1870
  let occurrence = keyedId(prop, raw);
@@ -2226,25 +2265,23 @@ function snapshot(shared, have) {
2226
2265
  });
2227
2266
  open.r[k] = record;
2228
2267
  };
2229
- if (!conditional) {
2230
- for (const {
2268
+ const containers = [];
2269
+ const spliced = new Set();
2270
+ for (const entry of shared.records.values()) {
2271
+ const {
2231
2272
  id,
2232
- version,
2233
2273
  k,
2234
2274
  record
2235
- } of shared.records.values()) put(id, version, k, record);
2236
- return out;
2237
- }
2238
- const containers = [];
2239
- for (const e of shared.records.values()) if (e.id === shared.id && (e.k === "" || /^seg:[^:]+$/.test(e.k)) && e.record) containers.push({
2240
- e,
2241
- value: e.record.value
2242
- });
2243
- for (const {
2244
- k,
2245
- record
2246
- } of shared.records.values()) {
2247
- if (!k.startsWith("hole:lh:") || k.endsWith(":error") || !record || record.value == null) continue;
2275
+ } = entry;
2276
+ if (id !== shared.id || !record) continue;
2277
+ if (k === "" || /^seg:[^:]+$/.test(k)) {
2278
+ if (typeof record.value === "string") containers.push({
2279
+ e: entry,
2280
+ value: record.value
2281
+ });
2282
+ continue;
2283
+ }
2284
+ if (!k.startsWith("hole:lh:") || k.endsWith(":error") || record.value == null) continue;
2248
2285
  const n = k.slice(8);
2249
2286
  const startMark = `<!--lh:${n}-->`;
2250
2287
  const endMark = `<!--lh:/${n}-->`;
@@ -2254,9 +2291,32 @@ function snapshot(shared, have) {
2254
2291
  const end = c.value.indexOf(endMark, start);
2255
2292
  if (end < 0) continue;
2256
2293
  c.value = c.value.slice(0, start + startMark.length) + record.value + c.value.slice(end);
2294
+ spliced.add(entry);
2257
2295
  break;
2258
2296
  }
2259
2297
  }
2298
+ if (!conditional) {
2299
+ for (const e of shared.records.values()) {
2300
+ const {
2301
+ id,
2302
+ version,
2303
+ k,
2304
+ record
2305
+ } = e;
2306
+ if (spliced.has(e)) continue;
2307
+ const c = containers.find(c => c.e === e);
2308
+ if (c && c.value !== record.value) {
2309
+ const holes = {};
2310
+ if (record.holes) for (const key in record.holes) if (key.startsWith("lha:")) holes[key] = record.holes[key];
2311
+ put(id, version, k, withHoles({
2312
+ ...record,
2313
+ value: c.value,
2314
+ digest: k ? textDigest(c.value) : record.digest
2315
+ }, holeDigests(c.value, null, holes)));
2316
+ } else put(id, version, k, record);
2317
+ }
2318
+ return out;
2319
+ }
2260
2320
  for (const e of shared.records.values()) {
2261
2321
  const {
2262
2322
  id,
@@ -364,7 +364,7 @@ function connect(response, wire, address, binding, host, bump, begin) {
364
364
  const dead = error || cancelled || new Error("Frame stream ended before the frame completed.");
365
365
  connection.done = true;
366
366
  resolveEnd({
367
- open: open.size,
367
+ open: cancelled !== undefined ? Math.max(open.size, 1) : open.size,
368
368
  error: dead,
369
369
  sweep: () => {
370
370
  for (const [id, version] of open) host.apply({
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@solidjs/web",
3
3
  "description": "Solid's web runtime: client rendering, hydration, SSR, and DOM-specific control flow (Portal, Dynamic).",
4
- "version": "2.0.0-rc.21",
4
+ "version": "2.0.0-rc.23",
5
5
  "author": "Ryan Carniato",
6
6
  "license": "MIT",
7
7
  "homepage": "https://solidjs.com",
@@ -372,14 +372,15 @@
372
372
  "coverage": "vitest run --coverage",
373
373
  "bench": "vitest bench --run",
374
374
  "bench:server": "vitest bench --run --config vite.config.server-bench.mjs",
375
- "test-types": "tsc --project tsconfig.test.json && tsc --project tsconfig.test.augment.json"
375
+ "test-types": "tsc --project tsconfig.test.json && tsc --project tsconfig.test.augment.json && tsc --project tsconfig.test.libcheck.json"
376
376
  },
377
377
  "dependencies": {
378
- "seroval": "1.7.0",
379
- "seroval-plugins": "1.7.0"
378
+ "csstype": "^3.1.0",
379
+ "seroval": "^1.8.0",
380
+ "seroval-plugins": "^1.8.0"
380
381
  },
381
382
  "peerDependencies": {
382
- "solid-js": "^2.0.0-rc.21"
383
+ "solid-js": "^2.0.0-rc.23"
383
384
  },
384
385
  "devDependencies": {
385
386
  "@codspeed/vitest-plugin": "^5.4.0",
@@ -269,7 +269,7 @@ function createKeyedSerializer(serialize, onError, onDone) {
269
269
  stream = serialize(key, value, {
270
270
  onError: onError && (err => {
271
271
  failed = true;
272
- onError(err);
272
+ onError(err, key);
273
273
  if (cancel) {
274
274
  cancel();
275
275
  settle();
@@ -342,7 +342,7 @@ function createHydrationSerializer({
342
342
  });
343
343
  return createKeyedSerializer(late ? late(serialize, refs, onData, scopeId) : serialize, onError, onDone);
344
344
  }
345
- function rejectUnserializedKey(serialize, refs, onData, scopeId) {
345
+ function rejectUnserializedKey(serialize, refs, onData, scopeId, plain) {
346
346
  let taken = 0;
347
347
  let fresh = [];
348
348
  const set = refs.set;
@@ -365,8 +365,9 @@ function rejectUnserializedKey(serialize, refs, onData, scopeId) {
365
365
  if (ref instanceof Promise) ids.add(id + 1);else if (isStream(ref) || Object.getPrototypeOf(ref) === Object.prototype && !Object.keys(ref).length) ids.add(id);
366
366
  }
367
367
  if (!ids.size) return;
368
- const body = "for(const i of[" + [...ids] + "]){const v=$R[i];v&&(v.f?v.f(e):v.throw&&v.throw(e))}";
369
- const message = JSON.stringify("Serialization failed: the hydration value for key " + JSON.stringify(key) + " could not be serialized on the server").replace(/[<\u2028\u2029]/g, c => KEY_ESCAPES[c]);
368
+ const text = plain && plain(key);
369
+ const body = "for(const i of[" + [...ids] + "]){const v=$R[i];v&&(v.f?" + (text === undefined ? "v.f(e)" : "(v.f(e),v.p.s||(v.p.s=2,v.p.v=e))") + ":v.throw&&v.throw(e))}";
370
+ const message = JSON.stringify(text === undefined ? "Serialization failed: the hydration value for key " + JSON.stringify(key) + " could not be serialized on the server" : text).replace(/[<\u2028\u2029]/g, c => KEY_ESCAPES[c]);
370
371
  onData("($R=>{const e=new Error(" + message + ");" + body + "})(" + (scopeId == null ? "$R" : '$R["' + serializeKey(scopeId) + '"]') + ")");
371
372
  };
372
373
  return serialize(key, value, {
@@ -127,9 +127,16 @@ export declare function createHydrationSerializer(options: HydrationSerializerOp
127
127
  * reference a slot the client never filled and resolve `undefined`; it
128
128
  * parses the value again and fails on its own. seroval takes the next index
129
129
  * from `refs.size`, so the size counts every index ever taken.
130
+ *
131
+ * `plain(key)` answers with a message when the failure is the key's own
132
+ * rejection and the renderer sends a plain `Error` in its place (#4709): an
133
+ * `<Errored>` drew its fallback from that error, so the promise is rejected
134
+ * with the message and marked the way seroval marks a rejection. The
135
+ * hydrating read then throws it in the claim pass, against the fallback's
136
+ * markup.
130
137
  * @internal
131
138
  */
132
- export declare function rejectUnserializedKey(serialize: any, refs: any, onData: any, scopeId: any): (key: any, value: any, callbacks: any, live: any) => any; /**
139
+ export declare function rejectUnserializedKey(serialize: any, refs: any, onData: any, scopeId: any, plain: any): (key: any, value: any, callbacks: any, live: any) => any; /**
133
140
  * Renderer primitive — returns the cross-reference bootstrap script SSR
134
141
  * emits ahead of hydration data for a render scope. Not meant for
135
142
  * hand-written code.
@@ -127,9 +127,16 @@ export declare function createHydrationSerializer(options: HydrationSerializerOp
127
127
  * reference a slot the client never filled and resolve `undefined`; it
128
128
  * parses the value again and fails on its own. seroval takes the next index
129
129
  * from `refs.size`, so the size counts every index ever taken.
130
+ *
131
+ * `plain(key)` answers with a message when the failure is the key's own
132
+ * rejection and the renderer sends a plain `Error` in its place (#4709): an
133
+ * `<Errored>` drew its fallback from that error, so the promise is rejected
134
+ * with the message and marked the way seroval marks a rejection. The
135
+ * hydrating read then throws it in the claim pass, against the fallback's
136
+ * markup.
130
137
  * @internal
131
138
  */
132
- export declare function rejectUnserializedKey(serialize: any, refs: any, onData: any, scopeId: any): (key: any, value: any, callbacks: any, live: any) => any; /**
139
+ export declare function rejectUnserializedKey(serialize: any, refs: any, onData: any, scopeId: any, plain: any): (key: any, value: any, callbacks: any, live: any) => any; /**
133
140
  * Renderer primitive — returns the cross-reference bootstrap script SSR
134
141
  * emits ahead of hydration data for a render scope. Not meant for
135
142
  * hand-written code.
@@ -1,3 +1,5 @@
1
+ import { actionDepth } from 'solid-js/internal';
2
+
1
3
  const REVALIDATE_HEADER = "X-Revalidate";
2
4
 
3
5
  const RECORDS = Symbol.for("@solidjs/signals/observe/records");
@@ -205,8 +207,8 @@ function hasFlightMetadata(response) {
205
207
  }
206
208
  async function deliverFlightData(response, data) {
207
209
  if (data) await Promise.allSettled(Object.values(data).flatMap(s => s && typeof s == "object" ? Object.values(s) : []));
208
- const folded = (response.headers.get(SINGLE_FLIGHT_HEADER) || "").split(",");
209
- const metadata = hasFlightMetadata(response);
210
+ const folded = response.headers.get(SINGLE_FLIGHT_HEADER)?.split(",");
211
+ const metadata = !folded || hasFlightMetadata(response);
210
212
  for (const source of getFlightDataSourceIds()) {
211
213
  if (!metadata && !folded.includes(source)) continue;
212
214
  const consumer = getFlightDataConsumer(source);
@@ -936,10 +938,6 @@ async function createRequest(base, id, options, meta) {
936
938
  };
937
939
  delete options[CALL_OBSERVATION];
938
940
  }
939
- const flightSources = getFlightDataSourceIds();
940
- if (flightSources.length > 0 && !isReadCall(options)) {
941
- headers[SINGLE_FLIGHT_HEADER] = flightSources.join(",");
942
- }
943
941
  let init = {
944
942
  method: "POST",
945
943
  ...options,
@@ -1044,6 +1042,16 @@ async function dispatchServerFunction(base, id, options, args, meta, callArgs =
1044
1042
  id,
1045
1043
  meta
1046
1044
  }) : undefined;
1045
+ const sources = getFlightDataSourceIds();
1046
+ const mutation = !isReadCall(options) && sources.length > 0;
1047
+ const acted = mutation && actionDepth;
1048
+ if (acted) options = {
1049
+ ...options,
1050
+ headers: {
1051
+ ...options.headers,
1052
+ [SINGLE_FLIGHT_HEADER]: sources + ""
1053
+ }
1054
+ };
1047
1055
  const sent = options;
1048
1056
  const controller = options.signal ? undefined : new AbortController();
1049
1057
  if (controller) options = {
@@ -1074,7 +1082,7 @@ async function dispatchServerFunction(base, id, options, args, meta, callArgs =
1074
1082
  throw serverFunctionFailure(response, undefined);
1075
1083
  }
1076
1084
  const failed = response.headers.has(ERROR_HEADER);
1077
- if (!isReadCall(options) && getFlightDataSourceIds().length > 0) {
1085
+ if (mutation) {
1078
1086
  const folded = response.headers.has(SINGLE_FLIGHT_HEADER);
1079
1087
  const metadata = hasFlightMetadata(response);
1080
1088
  if (metadata || folded) {
@@ -1098,6 +1106,7 @@ async function dispatchServerFunction(base, id, options, args, meta, callArgs =
1098
1106
  if (failed) {
1099
1107
  throw serverFunctionFailure(response, result);
1100
1108
  }
1109
+ if (acted) await deliverFlightData(response);
1101
1110
  if (controller && result?.[Symbol.asyncIterator]) {
1102
1111
  return {
1103
1112
  [Symbol.asyncIterator]() {
@@ -1,3 +1,5 @@
1
+ import { actionDepth } from 'solid-js/internal';
2
+
1
3
  const REVALIDATE_HEADER = "X-Revalidate";
2
4
 
3
5
  const SERVER_FUNCTION_METADATA = Symbol.for("solid.ServerFunctionMetadata");
@@ -98,8 +100,8 @@ function hasFlightMetadata(response) {
98
100
  }
99
101
  async function deliverFlightData(response, data) {
100
102
  if (data) await Promise.allSettled(Object.values(data).flatMap(s => s && typeof s == "object" ? Object.values(s) : []));
101
- const folded = (response.headers.get(SINGLE_FLIGHT_HEADER) || "").split(",");
102
- const metadata = hasFlightMetadata(response);
103
+ const folded = response.headers.get(SINGLE_FLIGHT_HEADER)?.split(",");
104
+ const metadata = !folded || hasFlightMetadata(response);
103
105
  for (const source of getFlightDataSourceIds()) {
104
106
  if (!metadata && !folded.includes(source)) continue;
105
107
  const consumer = getFlightDataConsumer(source);
@@ -821,10 +823,6 @@ async function createRequest(base, id, options, meta) {
821
823
  if (wire.position !== undefined) headers[LAST_EVENT_ID_HEADER] = wire.position;
822
824
  if (wire.headers) Object.assign(headers, wire.headers);
823
825
  }
824
- const flightSources = getFlightDataSourceIds();
825
- if (flightSources.length > 0 && !isReadCall(options)) {
826
- headers[SINGLE_FLIGHT_HEADER] = flightSources.join(",");
827
- }
828
826
  let init = {
829
827
  method: "POST",
830
828
  ...options,
@@ -915,6 +913,16 @@ async function dispatchServerFunction(base, id, options, args, meta, callArgs =
915
913
  id,
916
914
  meta
917
915
  }) : undefined;
916
+ const sources = getFlightDataSourceIds();
917
+ const mutation = !isReadCall(options) && sources.length > 0;
918
+ const acted = mutation && actionDepth;
919
+ if (acted) options = {
920
+ ...options,
921
+ headers: {
922
+ ...options.headers,
923
+ [SINGLE_FLIGHT_HEADER]: sources + ""
924
+ }
925
+ };
918
926
  const sent = options;
919
927
  const controller = options.signal ? undefined : new AbortController();
920
928
  if (controller) options = {
@@ -938,7 +946,7 @@ async function dispatchServerFunction(base, id, options, args, meta, callArgs =
938
946
  throw serverFunctionFailure(response, undefined);
939
947
  }
940
948
  const failed = response.headers.has(ERROR_HEADER);
941
- if (!isReadCall(options) && getFlightDataSourceIds().length > 0) {
949
+ if (mutation) {
942
950
  const folded = response.headers.has(SINGLE_FLIGHT_HEADER);
943
951
  const metadata = hasFlightMetadata(response);
944
952
  if (metadata || folded) {
@@ -962,6 +970,7 @@ async function dispatchServerFunction(base, id, options, args, meta, callArgs =
962
970
  if (failed) {
963
971
  throw serverFunctionFailure(response, result);
964
972
  }
973
+ if (acted) await deliverFlightData(response);
965
974
  if (controller && result?.[Symbol.asyncIterator]) {
966
975
  return {
967
976
  [Symbol.asyncIterator]() {
@@ -1,3 +1,5 @@
1
+ import { actionDepth } from 'solid-js/internal';
2
+
1
3
  const REVALIDATE_HEADER = "X-Revalidate";
2
4
 
3
5
  const RECORDS = Symbol.for("@solidjs/signals/observe/records");
@@ -205,8 +207,8 @@ function hasFlightMetadata(response) {
205
207
  }
206
208
  async function deliverFlightData(response, data) {
207
209
  if (data) await Promise.allSettled(Object.values(data).flatMap(s => s && typeof s == "object" ? Object.values(s) : []));
208
- const folded = (response.headers.get(SINGLE_FLIGHT_HEADER) || "").split(",");
209
- const metadata = hasFlightMetadata(response);
210
+ const folded = response.headers.get(SINGLE_FLIGHT_HEADER)?.split(",");
211
+ const metadata = !folded || hasFlightMetadata(response);
210
212
  for (const source of getFlightDataSourceIds()) {
211
213
  if (!metadata && !folded.includes(source)) continue;
212
214
  const consumer = getFlightDataConsumer(source);
@@ -936,10 +938,6 @@ async function createRequest(base, id, options, meta) {
936
938
  };
937
939
  delete options[CALL_OBSERVATION];
938
940
  }
939
- const flightSources = getFlightDataSourceIds();
940
- if (flightSources.length > 0 && !isReadCall(options)) {
941
- headers[SINGLE_FLIGHT_HEADER] = flightSources.join(",");
942
- }
943
941
  let init = {
944
942
  method: "POST",
945
943
  ...options,
@@ -1044,6 +1042,16 @@ async function dispatchServerFunction(base, id, options, args, meta, callArgs =
1044
1042
  id,
1045
1043
  meta
1046
1044
  }) : undefined;
1045
+ const sources = getFlightDataSourceIds();
1046
+ const mutation = !isReadCall(options) && sources.length > 0;
1047
+ const acted = mutation && actionDepth;
1048
+ if (acted) options = {
1049
+ ...options,
1050
+ headers: {
1051
+ ...options.headers,
1052
+ [SINGLE_FLIGHT_HEADER]: sources + ""
1053
+ }
1054
+ };
1047
1055
  const sent = options;
1048
1056
  const controller = options.signal ? undefined : new AbortController();
1049
1057
  if (controller) options = {
@@ -1074,7 +1082,7 @@ async function dispatchServerFunction(base, id, options, args, meta, callArgs =
1074
1082
  throw serverFunctionFailure(response, undefined);
1075
1083
  }
1076
1084
  const failed = response.headers.has(ERROR_HEADER);
1077
- if (!isReadCall(options) && getFlightDataSourceIds().length > 0) {
1085
+ if (mutation) {
1078
1086
  const folded = response.headers.has(SINGLE_FLIGHT_HEADER);
1079
1087
  const metadata = hasFlightMetadata(response);
1080
1088
  if (metadata || folded) {
@@ -1098,6 +1106,7 @@ async function dispatchServerFunction(base, id, options, args, meta, callArgs =
1098
1106
  if (failed) {
1099
1107
  throw serverFunctionFailure(response, result);
1100
1108
  }
1109
+ if (acted) await deliverFlightData(response);
1101
1110
  if (controller && result?.[Symbol.asyncIterator]) {
1102
1111
  return {
1103
1112
  [Symbol.asyncIterator]() {