Skip to content

Commit

Permalink
Revert "Remove pump (#1730)"
Browse files Browse the repository at this point in the history
This reverts commit 0c52d61.
  • Loading branch information
matthewwalsh0 committed Sep 16, 2023
1 parent 1d7a1ff commit be490f1
Show file tree
Hide file tree
Showing 20 changed files with 178 additions and 188 deletions.
2 changes: 2 additions & 0 deletions packages/snaps-controllers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
"json-rpc-engine": "^6.1.0",
"json-rpc-middleware-stream": "^4.2.0",
"nanoid": "^3.1.31",
"pump": "^3.0.0",
"readable-web-to-node-stream": "^3.0.2",
"tar-stream": "^2.2.0"
},
Expand All @@ -83,6 +84,7 @@
"@types/jest": "^27.5.1",
"@types/mocha": "^10.0.1",
"@types/node": "18.14.2",
"@types/pump": "^1.1.1",
"@types/readable-stream": "^2.3.15",
"@types/tar-stream": "^2.2.2",
"@typescript-eslint/eslint-plugin": "^5.42.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import type {
import { JsonRpcEngine } from 'json-rpc-engine';
import { createStreamMiddleware } from 'json-rpc-middleware-stream';
import { nanoid } from 'nanoid';
import { pipeline } from 'stream';
import pump from 'pump';
import type { Duplex } from 'stream';

import { log } from '../logging';
Expand Down Expand Up @@ -182,16 +182,7 @@ export abstract class AbstractExecutionService<WorkerType>

const jsonRpcConnection = createStreamMiddleware();

pipeline(
jsonRpcConnection.stream,
streams.command,
jsonRpcConnection.stream,
(error) => {
if (error) {
logError(`Command stream failure.`, error);
}
},
);
pump(jsonRpcConnection.stream, streams.command, jsonRpcConnection.stream);

rpcEngine.push(jsonRpcConnection.middleware);

Expand Down Expand Up @@ -457,7 +448,7 @@ export function setupMultiplex(
streamName: string,
): ObjectMultiplex {
const mux = new ObjectMultiplex();
pipeline(
pump(
connectionStream,
// Typecast: stream type mismatch
mux as unknown as Duplex,
Expand Down
15 changes: 3 additions & 12 deletions packages/snaps-controllers/src/snaps/SnapController.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {
DEFAULT_REQUESTED_SNAP_VERSION,
getSnapChecksum,
HandlerType,
logError,
SnapCaveatType,
SnapStatus,
VirtualFile,
Expand All @@ -36,7 +35,7 @@ import { ethErrors } from 'eth-rpc-errors';
import fetchMock from 'jest-fetch-mock';
import { createAsyncMiddleware, JsonRpcEngine } from 'json-rpc-engine';
import { createEngineStream } from 'json-rpc-middleware-stream';
import { pipeline } from 'stream';
import pump from 'pump';
import type { Duplex } from 'stream';

import type { NodeThreadExecutionService } from '../services';
Expand Down Expand Up @@ -1103,11 +1102,7 @@ describe('SnapController', () => {
});
engine.push(middleware);
const providerStream = createEngineStream({ engine });
pipeline(stream, providerStream, stream, (error) => {
if (error) {
logError(`Provider stream failure.`, error);
}
});
pump(stream, providerStream, stream);
});

await snapController.startSnap(snap.id);
Expand Down Expand Up @@ -1188,11 +1183,7 @@ describe('SnapController', () => {
});
engine.push(middleware);
const providerStream = createEngineStream({ engine });
pipeline(stream, providerStream, stream, (error) => {
if (error) {
logError(`Provider stream failure.`, error);
}
});
pump(stream, providerStream, stream);
});

await snapController.startSnap(snap.id);
Expand Down
4 changes: 2 additions & 2 deletions packages/snaps-controllers/src/snaps/location/npm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import {
} from '@metamask/utils';
import concat from 'concat-stream';
import createGunzipStream from 'gunzip-maybe';
import pump from 'pump';
import { ReadableWebToNodeStream } from 'readable-web-to-node-stream';
import { pipeline } from 'stream';
import type { Readable, Writable } from 'stream';
import { extract as tarExtract } from 'tar-stream';

Expand Down Expand Up @@ -182,7 +182,7 @@ export class NpmLocation implements SnapLocation {
// We would need to replace tar-stream package because it requires immediate consumption of streams.
await new Promise<void>((resolve, reject) => {
this.files = new Map();
pipeline(
pump(
getNodeStream(tarballResponse),
// The "gz" in "tgz" stands for "gzip". The tarball needs to be decompressed
// before we can actually grab any files from it.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { logError, type SnapRpcHookArgs } from '@metamask/snaps-utils';
import type { SnapRpcHookArgs } from '@metamask/snaps-utils';
import type { MockControllerMessenger } from '@metamask/snaps-utils/test-utils';
import { JsonRpcEngine } from 'json-rpc-engine';
import { createEngineStream } from 'json-rpc-middleware-stream';
import { pipeline } from 'stream';
import pump from 'pump';

import type {
ExecutionService,
Expand Down Expand Up @@ -58,11 +58,7 @@ export const getNodeEES = (messenger: ReturnType<typeof getNodeEESMessenger>) =>
return next();
});
const providerStream = createEngineStream({ engine });
pipeline(stream, providerStream, stream, (error) => {
if (error) {
logError(`Provider stream failure.`, error);
}
});
pump(stream, providerStream, stream);
}),
});

Expand Down
9 changes: 2 additions & 7 deletions packages/snaps-controllers/src/test-utils/service.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { ControllerMessenger } from '@metamask/base-controller';
import { logError } from '@metamask/snaps-utils';
import { JsonRpcEngine } from 'json-rpc-engine';
import { createEngineStream } from 'json-rpc-middleware-stream';
import { pipeline } from 'stream';
import pump from 'pump';
import type { Duplex } from 'stream';

import type { ErrorMessageEvent } from '../services';
Expand Down Expand Up @@ -57,11 +56,7 @@ export const createService = <
return next();
});
const providerStream = createEngineStream({ engine });
pipeline(stream, providerStream, stream, (error) => {
if (error) {
logError(`Provider stream failure.`, error);
}
});
pump(stream, providerStream, stream);
},
...options,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,9 @@
"console.warn": true
},
"packages": {
"@metamask/object-multiplex>end-of-stream": true,
"@metamask/object-multiplex>once": true,
"@metamask/object-multiplex>readable-stream": true
}
},
"@metamask/object-multiplex>end-of-stream": {
"packages": {
"@metamask/object-multiplex>once": true,
"browserify>process": true
}
},
"@metamask/object-multiplex>once": {
"packages": {
"@metamask/object-multiplex>once>wrappy": true
"@metamask/object-multiplex>readable-stream": true,
"pump>end-of-stream": true,
"pump>once": true
}
},
"@metamask/object-multiplex>readable-stream": {
Expand Down Expand Up @@ -106,10 +95,10 @@
"@metamask/providers>extension-port-stream": true,
"@metamask/providers>is-stream": true,
"@metamask/providers>json-rpc-middleware-stream": true,
"@metamask/providers>pump": true,
"eslint>fast-deep-equal": true,
"eth-rpc-errors": true,
"json-rpc-engine": true
"json-rpc-engine": true,
"pump": true
}
},
"@metamask/providers>@metamask/safe-event-emitter": {
Expand Down Expand Up @@ -170,14 +159,6 @@
"@metamask/providers>json-rpc-middleware-stream>readable-stream>safe-buffer": true
}
},
"@metamask/providers>pump": {
"packages": {
"@metamask/object-multiplex>end-of-stream": true,
"@metamask/object-multiplex>once": true,
"browserify>browser-resolve": true,
"browserify>process": true
}
},
"@metamask/utils": {
"globals": {
"TextDecoder": true,
Expand Down Expand Up @@ -346,6 +327,25 @@
"browserify>events": true
}
},
"pump": {
"packages": {
"browserify>browser-resolve": true,
"browserify>process": true,
"pump>end-of-stream": true,
"pump>once": true
}
},
"pump>end-of-stream": {
"packages": {
"browserify>process": true,
"pump>once": true
}
},
"pump>once": {
"packages": {
"pump>once>wrappy": true
}
},
"superstruct": {
"globals": {
"console.warn": true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,9 @@
"console.warn": true
},
"packages": {
"@metamask/object-multiplex>end-of-stream": true,
"@metamask/object-multiplex>once": true,
"@metamask/object-multiplex>readable-stream": true
}
},
"@metamask/object-multiplex>end-of-stream": {
"globals": {
"process.nextTick": true
},
"packages": {
"@metamask/object-multiplex>once": true
}
},
"@metamask/object-multiplex>once": {
"packages": {
"@metamask/object-multiplex>once>wrappy": true
"@metamask/object-multiplex>readable-stream": true,
"pump>end-of-stream": true,
"pump>once": true
}
},
"@metamask/object-multiplex>readable-stream": {
Expand Down Expand Up @@ -146,10 +133,10 @@
"@metamask/providers>extension-port-stream": true,
"@metamask/providers>is-stream": true,
"@metamask/providers>json-rpc-middleware-stream": true,
"@metamask/providers>pump": true,
"eslint>fast-deep-equal": true,
"eth-rpc-errors": true,
"json-rpc-engine": true
"json-rpc-engine": true,
"pump": true
}
},
"@metamask/providers>@metamask/safe-event-emitter": {
Expand Down Expand Up @@ -231,19 +218,6 @@
"@metamask/providers>json-rpc-middleware-stream>readable-stream>safe-buffer": true
}
},
"@metamask/providers>pump": {
"builtin": {
"fs": true
},
"globals": {
"process.version": true
},
"packages": {
"@metamask/object-multiplex>end-of-stream": true,
"@metamask/object-multiplex>once": true,
"fs": true
}
},
"@metamask/utils": {
"builtin": {
"buffer.Buffer": true
Expand Down Expand Up @@ -420,6 +394,32 @@
"events": true
}
},
"pump": {
"builtin": {
"fs": true
},
"globals": {
"process.version": true
},
"packages": {
"fs": true,
"pump>end-of-stream": true,
"pump>once": true
}
},
"pump>end-of-stream": {
"globals": {
"process.nextTick": true
},
"packages": {
"pump>once": true
}
},
"pump>once": {
"packages": {
"pump>once>wrappy": true
}
},
"superstruct": {
"globals": {
"console.warn": true,
Expand Down
Loading

0 comments on commit be490f1

Please sign in to comment.