@se-studio/project-build 1.1.19 → 1.1.20

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @se-studio/project-build
2
2
 
3
+ ## 1.1.20
4
+
5
+ ### Patch Changes
6
+
7
+ - b5a613d: Keep Next's empty dev debug stream from blocking React hydration. The stream stays open, and the dev Flight clients no longer wait on it.
8
+
3
9
  ## 1.1.19
4
10
 
5
11
  ### Patch Changes
@@ -5,9 +5,12 @@
5
5
  * debug graph into the browser over the HMR socket. A large page (a directory
6
6
  * of cards) crashes the Chrome renderer. Production builds never open it.
7
7
  *
8
- * The client gets an empty stream that stays open. Closing it makes Flight
9
- * throw "Connection closed" and the page fails to hydrate. The server drains
10
- * the readable and does not send chunks to the tab. Turbopack HMR is separate.
8
+ * The client keeps an open empty stream. Closing it makes Flight call close()
9
+ * and throw "Connection closed." Leaving hasReadable set makes React wait for
10
+ * debug rows that never arrive, so hydration never commits. This patch leaves
11
+ * the stream open and forces hasReadable false in the dev Flight clients.
12
+ * The server drains its readable and does not send chunks to the tab.
13
+ * Turbopack HMR is separate.
11
14
  *
12
15
  * `pnpm install` restores Next. The next `next dev` start applies this again.
13
16
  * Called from ensureNextDevFlightPatch so existing next.config.ts files pick
@@ -17,6 +20,7 @@ const fs = require('node:fs');
17
20
  const path = require('node:path');
18
21
 
19
22
  const MARKER = 'se-lab-drop-browser-debug-channel';
23
+ const WAIT_MARKER = 'se-lab-debug-channel-do-not-wait';
20
24
 
21
25
  const PRODUCTION_PHASES = new Set([
22
26
  'phase-production-build',
@@ -131,6 +135,41 @@ function writeIfChanged(filePath, patch) {
131
135
  return 'patched';
132
136
  }
133
137
 
138
+ const HAS_READABLE = 'hasReadable: void 0 !== options.debugChannel.readable';
139
+ const HAS_READABLE_OFF = `hasReadable: !1 /* ${WAIT_MARKER} */`;
140
+
141
+ function patchDebugWait(source) {
142
+ if (source.includes(WAIT_MARKER)) {
143
+ return { source, changed: false };
144
+ }
145
+ if (!source.includes(HAS_READABLE)) {
146
+ return { source, changed: false, missing: true };
147
+ }
148
+ return { source: source.replaceAll(HAS_READABLE, HAS_READABLE_OFF), changed: true };
149
+ }
150
+
151
+ function reactDevClients(root) {
152
+ const compiled = path.join(root, 'dist/compiled');
153
+ if (!fs.existsSync(compiled)) {
154
+ return [];
155
+ }
156
+ const found = [];
157
+ for (const entry of fs.readdirSync(compiled, { recursive: true, withFileTypes: true })) {
158
+ if (!entry.isFile() || !entry.name.endsWith('.development.js')) {
159
+ continue;
160
+ }
161
+ const filePath = path.join(
162
+ entry.parentPath ?? path.join(compiled, entry.path ?? ''),
163
+ entry.name,
164
+ );
165
+ found.push(filePath);
166
+ }
167
+ return found.filter((filePath) => {
168
+ const source = fs.readFileSync(filePath, 'utf8');
169
+ return source.includes(HAS_READABLE) || source.includes(WAIT_MARKER);
170
+ });
171
+ }
172
+
134
173
  function ensureNextDevBrowserDebugPatch(cwd = process.cwd(), env = process.env) {
135
174
  if (!shouldPatch(env)) {
136
175
  return null;
@@ -145,9 +184,19 @@ function ensureNextDevBrowserDebugPatch(cwd = process.cwd(), env = process.env)
145
184
  const status = writeIfChanged(path.join(root, relativePath), patchServer);
146
185
  counts[status] += 1;
147
186
  }
187
+ const waitCounts = { patched: 0, already: 0, missing: 0 };
188
+ for (const filePath of reactDevClients(root)) {
189
+ const status = writeIfChanged(filePath, patchDebugWait);
190
+ waitCounts[status] += 1;
191
+ }
148
192
  console.log(
149
193
  `[patch-next-dev-browser-debug] done: ${counts.patched} patched, ${counts.already} already patched, ${counts.missing} pattern-missing`,
150
194
  );
195
+ if (waitCounts.patched || waitCounts.already) {
196
+ console.log(
197
+ `[patch-next-dev-browser-debug] debug wait: ${waitCounts.patched} patched, ${waitCounts.already} already patched`,
198
+ );
199
+ }
151
200
  return counts;
152
201
  }
153
202
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@se-studio/project-build",
3
- "version": "1.1.19",
3
+ "version": "1.1.20",
4
4
  "description": "Build tools and management scripts for SE Studio projects",
5
5
  "repository": {
6
6
  "type": "git",