| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 7dd32f1 commit da27542
19 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2321,7 +2321,8 @@ on unsupported platforms will not be fixed. | |||
| 2321 | 2321 | ### `NODE_TEST_CONTEXT=value` | |
| 2322 | 2322 | ||
| 2323 | 2323 | If `value` equals `'child'`, test reporter options will be overridden and test | |
| 2324 | - output will be sent to stdout in the TAP format. | ||
| 2324 | + output will be sent to stdout in the TAP format. If any other value is provided, | ||
| 2325 | + Node.js makes no guarantees about the reporter format used or its stability. | ||
| 2325 | 2326 | ||
| 2326 | 2327 | ### `NODE_TLS_REJECT_UNAUTHORIZED=value` | |
| 2327 | 2328 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,39 @@ | |||
| 1 | + 'use strict'; | ||
| 2 | + | ||
| 3 | + const { DefaultSerializer } = require('v8'); | ||
| 4 | + const { Buffer } = require('buffer'); | ||
| 5 | + const { serializeError } = require('internal/error_serdes'); | ||
| 6 | + | ||
| 7 | + | ||
| 8 | + module.exports = async function* v8Reporter(source) { | ||
| 9 | + const serializer = new DefaultSerializer(); | ||
| 10 | + | ||
| 11 | + for await (const item of source) { | ||
| 12 | + const originalError = item.data.details?.error; | ||
| 13 | + if (originalError) { | ||
| 14 | + // Error is overriden with a serialized version, so that it can be | ||
| 15 | + // deserialized in the parent process. | ||
| 16 | + // Error is restored after serialization. | ||
| 17 | + item.data.details.error = serializeError(originalError); | ||
| 18 | + } | ||
| 19 | + // Add 4 bytes, to later populate with message length | ||
| 20 | + serializer.writeRawBytes(Buffer.allocUnsafe(4)); | ||
| 21 | + serializer.writeHeader(); | ||
| 22 | + serializer.writeValue(item); | ||
| 23 | + | ||
| 24 | + if (originalError) { | ||
| 25 | + item.data.details.error = originalError; | ||
| 26 | + } | ||
| 27 | + | ||
| 28 | + const serializedMessage = serializer.releaseBuffer(); | ||
| 29 | + const serializedMessageLength = serializedMessage.length - 4; | ||
| 30 | + | ||
| 31 | + serializedMessage.set([ | ||
| 32 | + serializedMessageLength >> 24 & 0xFF, | ||
| 33 | + serializedMessageLength >> 16 & 0xFF, | ||
| 34 | + serializedMessageLength >> 8 & 0xFF, | ||
| 35 | + serializedMessageLength & 0xFF, | ||
| 36 | + ], 0); | ||
| 37 | + yield serializedMessage; | ||
| 38 | + } | ||
| 39 | + }; | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments