Skip to content

Commit 75d4219

Browse files
authored
Merge pull request #5710 from Ivan-Feofanov/main
Add streaming response
2 parents 7cbd23f + 859032f commit 75d4219

File tree

4 files changed

+17
-1
lines changed

4 files changed

+17
-1
lines changed

.changeset/warm-beans-tie.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"hardhat": patch
3+
---
4+
5+
Hardhat node can now handle large response objects by streaming them.

packages/hardhat-core/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@
128128
"glob": "7.2.0",
129129
"immutable": "^4.0.0-rc.12",
130130
"io-ts": "1.10.4",
131+
"json-stream-stringify": "^3.1.4",
131132
"keccak": "^3.0.2",
132133
"lodash": "^4.17.11",
133134
"mnemonist": "^0.38.0",

packages/hardhat-core/src/internal/hardhat-network/jsonrpc/handler.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { IncomingMessage, ServerResponse } from "http";
22
import getRawBody from "raw-body";
33
import WebSocket from "ws";
4+
import { JsonStreamStringify } from "json-stream-stringify";
45

56
import { EIP1193Provider } from "../../../types";
67
import {
@@ -135,7 +136,7 @@ export class JsonRpcHandler {
135136
) {
136137
res.statusCode = 200;
137138
res.setHeader("Content-Type", "application/json");
138-
res.end(JSON.stringify(rpcResp));
139+
new JsonStreamStringify(rpcResp).pipe(res);
139140
}
140141

141142
private async _handleSingleRequest(

pnpm-lock.yaml

+9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)