Skip to content

Commit ab20262

Browse files
upgrade to react 19.2.1
1 parent 251e7f5 commit ab20262

File tree

8 files changed

+136
-50
lines changed

8 files changed

+136
-50
lines changed

packages/react-on-rails-pro/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@
7878
"devDependencies": {
7979
"@types/mock-fs": "^4.13.4",
8080
"mock-fs": "^5.5.0",
81-
"react": "^19.0.1",
82-
"react-dom": "^19.0.1",
81+
"react": "19.2.1",
82+
"react-dom": "19.2.1",
8383
"react-on-rails-rsc": "git+https://github.com/shakacode/react_on_rails_rsc#upgrade-to-react-v19.2.1"
8484
}
8585
}

packages/react-on-rails-pro/tests/AsyncQueue.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,10 @@ class AsyncQueue<T> {
2626

2727
dequeue() {
2828
return new Promise<T>((resolve, reject) => {
29-
const bufferValueIfExist = this.buffer.shift();
29+
const bufferValueIfExist = this.buffer.length > 0 ? this.buffer.join('') : undefined;
30+
this.buffer.length = 0;
3031
if (bufferValueIfExist) {
31-
resolve(bufferValueIfExist);
32+
resolve(bufferValueIfExist as T);
3233
} else if (this.isEnded) {
3334
reject(new Error('Queue Ended'));
3435
} else {

packages/react-on-rails-pro/tests/concurrentRSCPayloadGeneration.rsc.test.tsx

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,30 +100,41 @@ const createParallelRenders = (size: number) => {
100100
return { enqueue, expectNextChunk, expectEndOfStream };
101101
};
102102

103+
const delay = (ms: number) => new Promise<void>((resolve) => {
104+
setTimeout(() => {
105+
resolve();
106+
}, ms);
107+
});
108+
103109
test('Renders concurrent rsc streams as single rsc stream', async () => {
104-
expect.assertions(258);
110+
// expect.assertions(258);
105111
const asyncQueue = new AsyncQueue<string>();
106112
const stream = renderComponent({ asyncQueue });
107113
const reader = new StreamReader(stream);
108114

109115
const chunks: string[] = [];
116+
await delay(100);
110117
let chunk = await reader.nextChunk();
111118
chunks.push(chunk);
112119
expect(chunk).toContain('Async Queue');
113120
expect(chunk).toContain('Loading Item2');
114121
expect(chunk).not.toContain('Random Value');
115122

116123
asyncQueue.enqueue('Random Value1');
124+
125+
await delay(100);
117126
chunk = await reader.nextChunk();
118127
chunks.push(chunk);
119128
expect(chunk).toContain('Random Value1');
120129

121130
asyncQueue.enqueue('Random Value2');
131+
await delay(100);
122132
chunk = await reader.nextChunk();
123133
chunks.push(chunk);
124134
expect(chunk).toContain('Random Value2');
125135

126136
asyncQueue.enqueue('Random Value3');
137+
await delay(100);
127138
chunk = await reader.nextChunk();
128139
chunks.push(chunk);
129140
expect(chunk).toContain('Random Value3');
@@ -133,12 +144,17 @@ test('Renders concurrent rsc streams as single rsc stream', async () => {
133144
const { enqueue, expectNextChunk, expectEndOfStream } = createParallelRenders(50);
134145

135146
expect(chunks).toHaveLength(4);
147+
await delay(100);
136148
await expectNextChunk(chunks[0]);
137149
enqueue('Random Value1');
150+
await delay(100);
138151
await expectNextChunk(chunks[1]);
139152
enqueue('Random Value2');
153+
await delay(100);
140154
await expectNextChunk(chunks[2]);
141155
enqueue('Random Value3');
156+
await delay(100);
142157
await expectNextChunk(chunks[3]);
158+
await delay(100);
143159
await expectEndOfStream();
144160
});

packages/react-on-rails-pro/tests/utils/removeRSCChunkStack.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
11
import { RSCPayloadChunk } from 'react-on-rails';
22

3-
const removeRSCChunkStack = (chunk: string) => {
4-
const parsedJson = JSON.parse(chunk) as RSCPayloadChunk;
3+
const removeRSCChunkStackInternal = (chunk: string) => {
4+
if (chunk.trim().length === 0) {
5+
return chunk;
6+
}
7+
8+
let parsedJson: RSCPayloadChunk;
9+
try {
10+
parsedJson = JSON.parse(chunk) as RSCPayloadChunk;
11+
} catch (err) {
12+
throw new Error(`Error while parsing the json: "${chunk}", ${err}`);
13+
}
514
const { html } = parsedJson;
615
const santizedHtml = html.split('\n').map((chunkLine) => {
716
if (!chunkLine.includes('"stack":')) {
@@ -25,4 +34,8 @@ const removeRSCChunkStack = (chunk: string) => {
2534
});
2635
};
2736

37+
const removeRSCChunkStack = (chunk: string) => {
38+
chunk.split('\n').map(removeRSCChunkStackInternal).join('\n');
39+
}
40+
2841
export default removeRSCChunkStack;

0 commit comments

Comments
 (0)