@tramvai/module-render 4.2.0 → 4.2.1

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.
@@ -113,7 +113,6 @@ class ReactRenderServer {
113
113
  });
114
114
  const timeout = this.streamingTimeout;
115
115
  const unfinishedActions = [];
116
- let isAborted = false;
117
116
  const { pipe, abort } = renderToPipeableStream(renderResult, {
118
117
  // we need to run hydration only after first chunk is sent to client
119
118
  // https://github.com/reactwg/react-18/discussions/114
@@ -136,16 +135,12 @@ class ReactRenderServer {
136
135
  },
137
136
  onError(error) {
138
137
  // error can be inside Suspense boundaries, this is not critical, continue rendering.
138
+ // also render stream `abort` method calls will trigger this callback.
139
139
  // for criticall errors, this callback will be called with `onShellError`,
140
140
  // so this is a best place to error logging
141
141
  log.error({
142
142
  event: 'streaming-render:error',
143
- error: isAborted
144
- ? new AbortedStreamError({
145
- reason: `${timeout}ms timeout exceeded`,
146
- unfinishedActions,
147
- })
148
- : error,
143
+ error,
149
144
  });
150
145
  },
151
146
  onShellError(error) {
@@ -155,7 +150,6 @@ class ReactRenderServer {
155
150
  });
156
151
  // global response stream timeo
157
152
  setTimeout(() => {
158
- isAborted = true;
159
153
  // abort unfinished deferred actions
160
154
  this.deferredActions.forEach((action, name) => {
161
155
  if (action.isRejected() || action.isResolved()) {
@@ -164,12 +158,13 @@ class ReactRenderServer {
164
158
  unfinishedActions.push(name);
165
159
  action.reject(new AbortedDeferredError());
166
160
  });
167
- // abort render stream
168
- abort();
169
- reject(new AbortedStreamError({
161
+ const reason = new AbortedStreamError({
170
162
  reason: `${timeout}ms timeout exceeded`,
171
163
  unfinishedActions,
172
- }));
164
+ });
165
+ // abort render stream
166
+ abort(reason);
167
+ reject(reason);
173
168
  }, timeout);
174
169
  });
175
170
  }
@@ -121,7 +121,6 @@ class ReactRenderServer {
121
121
  });
122
122
  const timeout = this.streamingTimeout;
123
123
  const unfinishedActions = [];
124
- let isAborted = false;
125
124
  const { pipe, abort } = renderToPipeableStream(renderResult, {
126
125
  // we need to run hydration only after first chunk is sent to client
127
126
  // https://github.com/reactwg/react-18/discussions/114
@@ -144,16 +143,12 @@ class ReactRenderServer {
144
143
  },
145
144
  onError(error) {
146
145
  // error can be inside Suspense boundaries, this is not critical, continue rendering.
146
+ // also render stream `abort` method calls will trigger this callback.
147
147
  // for criticall errors, this callback will be called with `onShellError`,
148
148
  // so this is a best place to error logging
149
149
  log.error({
150
150
  event: 'streaming-render:error',
151
- error: isAborted
152
- ? new errors.AbortedStreamError({
153
- reason: `${timeout}ms timeout exceeded`,
154
- unfinishedActions,
155
- })
156
- : error,
151
+ error,
157
152
  });
158
153
  },
159
154
  onShellError(error) {
@@ -163,7 +158,6 @@ class ReactRenderServer {
163
158
  });
164
159
  // global response stream timeo
165
160
  setTimeout(() => {
166
- isAborted = true;
167
161
  // abort unfinished deferred actions
168
162
  this.deferredActions.forEach((action, name) => {
169
163
  if (action.isRejected() || action.isResolved()) {
@@ -172,12 +166,13 @@ class ReactRenderServer {
172
166
  unfinishedActions.push(name);
173
167
  action.reject(new errors.AbortedDeferredError());
174
168
  });
175
- // abort render stream
176
- abort();
177
- reject(new errors.AbortedStreamError({
169
+ const reason = new errors.AbortedStreamError({
178
170
  reason: `${timeout}ms timeout exceeded`,
179
171
  unfinishedActions,
180
- }));
172
+ });
173
+ // abort render stream
174
+ abort(reason);
175
+ reject(reason);
181
176
  }, timeout);
182
177
  });
183
178
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tramvai/module-render",
3
- "version": "4.2.0",
3
+ "version": "4.2.1",
4
4
  "description": "",
5
5
  "browser": "lib/browser.js",
6
6
  "main": "lib/server.js",
@@ -26,13 +26,13 @@
26
26
  "@tinkoff/layout-factory": "0.5.1",
27
27
  "@tinkoff/errors": "0.5.1",
28
28
  "@tinkoff/url": "0.10.1",
29
- "@tinkoff/user-agent": "0.6.7",
30
- "@tramvai/module-client-hints": "4.2.0",
31
- "@tramvai/module-router": "4.2.0",
32
- "@tramvai/react": "4.2.0",
29
+ "@tinkoff/user-agent": "0.6.8",
30
+ "@tramvai/module-client-hints": "4.2.1",
31
+ "@tramvai/module-router": "4.2.1",
32
+ "@tramvai/react": "4.2.1",
33
33
  "@tramvai/safe-strings": "0.7.1",
34
- "@tramvai/tokens-render": "4.2.0",
35
- "@tramvai/experiments": "4.2.0",
34
+ "@tramvai/tokens-render": "4.2.1",
35
+ "@tramvai/experiments": "4.2.1",
36
36
  "@types/loadable__server": "^5.12.6",
37
37
  "node-fetch": "^2.6.1"
38
38
  },
@@ -40,14 +40,14 @@
40
40
  "@tinkoff/dippy": "0.10.2",
41
41
  "@tinkoff/utils": "^2.1.2",
42
42
  "@tinkoff/react-hooks": "0.3.1",
43
- "@tramvai/cli": "4.2.0",
44
- "@tramvai/core": "4.2.0",
45
- "@tramvai/module-common": "4.2.0",
46
- "@tramvai/state": "4.2.0",
47
- "@tramvai/test-helpers": "4.2.0",
48
- "@tramvai/tokens-common": "4.2.0",
49
- "@tramvai/tokens-router": "4.2.0",
50
- "@tramvai/tokens-server-private": "4.2.0",
43
+ "@tramvai/cli": "4.2.1",
44
+ "@tramvai/core": "4.2.1",
45
+ "@tramvai/module-common": "4.2.1",
46
+ "@tramvai/state": "4.2.1",
47
+ "@tramvai/test-helpers": "4.2.1",
48
+ "@tramvai/tokens-common": "4.2.1",
49
+ "@tramvai/tokens-router": "4.2.1",
50
+ "@tramvai/tokens-server-private": "4.2.1",
51
51
  "express": "^4.17.1",
52
52
  "prop-types": "^15.6.2",
53
53
  "react": ">=16.14.0",