| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 7b26606 commit 8601394
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -13,7 +13,7 @@ const { Worker, parentPort } = require('worker_threads'); | |||
| 13 | 13 | // the two event loops intermixing, as we are writing in a busy loop here. | |
| 14 | 14 | ||
| 15 | 15 | if (process.env.HAS_STARTED_WORKER) { | |
| 16 | - const server = http2.createServer(); | ||
| 16 | + const server = http2.createServer({ maxSessionInvalidFrames: 100 }); | ||
| 17 | 17 | server.on('stream', (stream) => { | |
| 18 | 18 | stream.respond({ | |
| 19 | 19 | 'content-type': 'text/plain', | |
@@ -59,16 +59,20 @@ const worker = new Worker(__filename).on('message', common.mustCall((port) => { | |||
| 59 | 59 | }); | |
| 60 | 60 | ||
| 61 | 61 | let gotError = false; | |
| 62 | + let streamId = 1; | ||
| 62 | 63 | ||
| 63 | 64 | function writeRequests() { | |
| 64 | - for (let i = 1; !gotError; i += 2) { | ||
| 65 | + for (let i = 1; i < 10 && !gotError; i++) { | ||
| 65 | 66 | h2header[3] = 1; // HEADERS | |
| 66 | 67 | h2header[4] = 0x5; // END_HEADERS|END_STREAM | |
| 67 | 68 | h2header.writeIntBE(1, 0, 3); // Length: 1 | |
| 68 | - h2header.writeIntBE(i, 5, 4); // Stream ID | ||
| 69 | + h2header.writeIntBE(streamId, 5, 4); // Stream ID | ||
| 70 | + streamId += 2; | ||
| 69 | 71 | // 0x88 = :status: 200 | |
| 70 | 72 | conn.write(Buffer.concat([h2header, Buffer.from([0x88])])); | |
| 71 | 73 | } | |
| 74 | + if (!gotError) | ||
| 75 | + setImmediate(writeRequests); | ||
| 72 | 76 | } | |
| 73 | 77 | ||
| 74 | 78 | conn.once('error', common.mustCall(() => { | |
| Back | FazBrowse Home | New Git URL |
0 commit comments