@smithy/core 3.34.0 → 3.34.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Change Log
2
2
 
3
+ ## 3.34.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 90e722f: error and backpressure fixes for AWS chunked encoding streams
8
+
3
9
  ## 3.34.0
4
10
 
5
11
  ### Minor Changes
@@ -1170,6 +1170,8 @@ const getAwsChunkedEncodingStream = (readableStream, options) => {
1170
1170
  checksumLocationName !== undefined &&
1171
1171
  streamHasher !== undefined;
1172
1172
  const digest = checksumRequired ? streamHasher(checksumAlgorithmFn, readableStream) : undefined;
1173
+ Promise.resolve(digest).catch(() => {
1174
+ });
1173
1175
  const reader = readableStream.getReader();
1174
1176
  return new ReadableStream({
1175
1177
  async pull(controller) {
@@ -1352,6 +1352,8 @@ const getAwsChunkedEncodingStream$1 = (readableStream, options) => {
1352
1352
  checksumLocationName !== undefined &&
1353
1353
  streamHasher !== undefined;
1354
1354
  const digest = checksumRequired ? streamHasher(checksumAlgorithmFn, readableStream) : undefined;
1355
+ Promise.resolve(digest).catch(() => {
1356
+ });
1355
1357
  const reader = readableStream.getReader();
1356
1358
  return new ReadableStream({
1357
1359
  async pull(controller) {
@@ -1384,8 +1386,12 @@ function getAwsChunkedEncodingStream(stream, options) {
1384
1386
  checksumLocationName !== undefined &&
1385
1387
  streamHasher !== undefined;
1386
1388
  const digest = checksumRequired ? streamHasher(checksumAlgorithmFn, readable) : undefined;
1389
+ Promise.resolve(digest).catch(() => {
1390
+ });
1387
1391
  const awsChunkedEncodingStream = new Readable({
1388
- read: () => { },
1392
+ read() {
1393
+ readable.resume();
1394
+ },
1389
1395
  });
1390
1396
  readable.on("data", (data) => {
1391
1397
  const length = bodyLengthChecker(data) || 0;
@@ -1394,16 +1400,27 @@ function getAwsChunkedEncodingStream(stream, options) {
1394
1400
  }
1395
1401
  awsChunkedEncodingStream.push(`${length.toString(16)}\r\n`);
1396
1402
  awsChunkedEncodingStream.push(data);
1397
- awsChunkedEncodingStream.push("\r\n");
1403
+ if (!awsChunkedEncodingStream.push("\r\n")) {
1404
+ readable.pause();
1405
+ }
1398
1406
  });
1407
+ readable.on("error", (err) => {
1408
+ awsChunkedEncodingStream.destroy(err);
1409
+ });
1410
+ readable.pause();
1399
1411
  readable.on("end", async () => {
1400
- awsChunkedEncodingStream.push(`0\r\n`);
1401
- if (checksumRequired) {
1402
- const checksum = base64Encoder(await digest);
1403
- awsChunkedEncodingStream.push(`${checksumLocationName}:${checksum}\r\n`);
1404
- awsChunkedEncodingStream.push(`\r\n`);
1412
+ try {
1413
+ awsChunkedEncodingStream.push(`0\r\n`);
1414
+ if (checksumRequired) {
1415
+ const checksum = base64Encoder(await digest);
1416
+ awsChunkedEncodingStream.push(`${checksumLocationName}:${checksum}\r\n`);
1417
+ awsChunkedEncodingStream.push(`\r\n`);
1418
+ }
1419
+ awsChunkedEncodingStream.push(null);
1420
+ }
1421
+ catch (err) {
1422
+ awsChunkedEncodingStream.destroy(err);
1405
1423
  }
1406
- awsChunkedEncodingStream.push(null);
1407
1424
  });
1408
1425
  return awsChunkedEncodingStream;
1409
1426
  }
@@ -1170,6 +1170,8 @@ const getAwsChunkedEncodingStream = (readableStream, options) => {
1170
1170
  checksumLocationName !== undefined &&
1171
1171
  streamHasher !== undefined;
1172
1172
  const digest = checksumRequired ? streamHasher(checksumAlgorithmFn, readableStream) : undefined;
1173
+ Promise.resolve(digest).catch(() => {
1174
+ });
1173
1175
  const reader = readableStream.getReader();
1174
1176
  return new ReadableStream({
1175
1177
  async pull(controller) {
@@ -6,6 +6,8 @@ export const getAwsChunkedEncodingStream = (readableStream, options) => {
6
6
  checksumLocationName !== undefined &&
7
7
  streamHasher !== undefined;
8
8
  const digest = checksumRequired ? streamHasher(checksumAlgorithmFn, readableStream) : undefined;
9
+ Promise.resolve(digest).catch(() => {
10
+ });
9
11
  const reader = readableStream.getReader();
10
12
  return new ReadableStream({
11
13
  async pull(controller) {
@@ -13,8 +13,12 @@ export function getAwsChunkedEncodingStream(stream, options) {
13
13
  checksumLocationName !== undefined &&
14
14
  streamHasher !== undefined;
15
15
  const digest = checksumRequired ? streamHasher(checksumAlgorithmFn, readable) : undefined;
16
+ Promise.resolve(digest).catch(() => {
17
+ });
16
18
  const awsChunkedEncodingStream = new Readable({
17
- read: () => { },
19
+ read() {
20
+ readable.resume();
21
+ },
18
22
  });
19
23
  readable.on("data", (data) => {
20
24
  const length = bodyLengthChecker(data) || 0;
@@ -23,16 +27,27 @@ export function getAwsChunkedEncodingStream(stream, options) {
23
27
  }
24
28
  awsChunkedEncodingStream.push(`${length.toString(16)}\r\n`);
25
29
  awsChunkedEncodingStream.push(data);
26
- awsChunkedEncodingStream.push("\r\n");
30
+ if (!awsChunkedEncodingStream.push("\r\n")) {
31
+ readable.pause();
32
+ }
27
33
  });
34
+ readable.on("error", (err) => {
35
+ awsChunkedEncodingStream.destroy(err);
36
+ });
37
+ readable.pause();
28
38
  readable.on("end", async () => {
29
- awsChunkedEncodingStream.push(`0\r\n`);
30
- if (checksumRequired) {
31
- const checksum = base64Encoder(await digest);
32
- awsChunkedEncodingStream.push(`${checksumLocationName}:${checksum}\r\n`);
33
- awsChunkedEncodingStream.push(`\r\n`);
39
+ try {
40
+ awsChunkedEncodingStream.push(`0\r\n`);
41
+ if (checksumRequired) {
42
+ const checksum = base64Encoder(await digest);
43
+ awsChunkedEncodingStream.push(`${checksumLocationName}:${checksum}\r\n`);
44
+ awsChunkedEncodingStream.push(`\r\n`);
45
+ }
46
+ awsChunkedEncodingStream.push(null);
47
+ }
48
+ catch (err) {
49
+ awsChunkedEncodingStream.destroy(err);
34
50
  }
35
- awsChunkedEncodingStream.push(null);
36
51
  });
37
52
  return awsChunkedEncodingStream;
38
53
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smithy/core",
3
- "version": "3.34.0",
3
+ "version": "3.34.1",
4
4
  "homepage": "https://github.com/smithy-lang/smithy-typescript/tree/main/packages/core",
5
5
  "license": "Apache-2.0",
6
6
  "author": {