Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove pump #1730

Merged
merged 5 commits into from
Sep 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions packages/snaps-controllers/coverage.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"branches": 88.95,
"functions": 95.69,
"lines": 96.9,
"statements": 96.56
"branches": 88.7,
"functions": 95,
"lines": 96.7,
"statements": 96.35
}
2 changes: 0 additions & 2 deletions packages/snaps-controllers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@
"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 @@ -84,7 +83,6 @@
"@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 { JsonRpcEngine } from 'json-rpc-engine';
import { createStreamMiddleware } from 'json-rpc-middleware-stream';
import { nanoid } from 'nanoid';
import pump from 'pump';
import { pipeline } from 'stream';
import type { Duplex } from 'stream';

import { log } from '../logging';
Expand Down Expand Up @@ -182,7 +182,16 @@

const jsonRpcConnection = createStreamMiddleware();

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

Check warning on line 191 in packages/snaps-controllers/src/services/AbstractExecutionService.ts

View check run for this annotation

Codecov / codecov/patch

packages/snaps-controllers/src/services/AbstractExecutionService.ts#L189-L191

Added lines #L189 - L191 were not covered by tests
}
},
);

rpcEngine.push(jsonRpcConnection.middleware);

Expand Down Expand Up @@ -448,7 +457,7 @@
streamName: string,
): ObjectMultiplex {
const mux = new ObjectMultiplex();
pump(
pipeline(
connectionStream,
// Typecast: stream type mismatch
mux as unknown as Duplex,
Expand Down
15 changes: 12 additions & 3 deletions packages/snaps-controllers/src/snaps/SnapController.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
DEFAULT_REQUESTED_SNAP_VERSION,
getSnapChecksum,
HandlerType,
logError,
SnapCaveatType,
SnapStatus,
VirtualFile,
Expand All @@ -35,7 +36,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 pump from 'pump';
import { pipeline } from 'stream';
import type { Duplex } from 'stream';

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

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

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();
pump(
pipeline(
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 type { SnapRpcHookArgs } from '@metamask/snaps-utils';
import { logError, 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 pump from 'pump';
import { pipeline } from 'stream';

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

Expand Down
9 changes: 7 additions & 2 deletions packages/snaps-controllers/src/test-utils/service.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
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 pump from 'pump';
import { pipeline } from 'stream';
import type { Duplex } from 'stream';

import type { ErrorMessageEvent } from '../services';
Expand Down Expand Up @@ -56,7 +57,11 @@ export const createService = <
return next();
});
const providerStream = createEngineStream({ engine });
pump(stream, providerStream, stream);
pipeline(stream, providerStream, stream, (error) => {
if (error) {
logError(`Provider stream failure.`, error);
}
});
},
...options,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,20 @@
"console.warn": true
},
"packages": {
"@metamask/object-multiplex>readable-stream": true,
"pump>end-of-stream": true,
"pump>once": true
"@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": {
Expand Down Expand Up @@ -95,10 +106,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,
"pump": true
"json-rpc-engine": true
}
},
"@metamask/providers>@metamask/safe-event-emitter": {
Expand Down Expand Up @@ -159,6 +170,14 @@
"@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 @@ -327,25 +346,6 @@
"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,9 +28,22 @@
"console.warn": true
},
"packages": {
"@metamask/object-multiplex>readable-stream": true,
"pump>end-of-stream": true,
"pump>once": true
"@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": {
Expand Down Expand Up @@ -133,10 +146,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,
"pump": true
"json-rpc-engine": true
}
},
"@metamask/providers>@metamask/safe-event-emitter": {
Expand Down Expand Up @@ -218,6 +231,19 @@
"@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 @@ -394,32 +420,6 @@
"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