Safely ignore error stack trace
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 35/100
- Tipo di issue
- Refactoring
- Chiarezza
- Da chiarire
- Stato di attività
- Ferma
- Stack tecnologico
- javascript, node.js
- Ambito
- performance
Direzione di ricerca
Inizia da bench/error.js e riproduci il benchmark che confronta gli errori normali con quelli con stackTraceLimit=0. Poi esamina i file Node.js indicati, inclusi lib/assert.js, lib/events.js, lib/internal/process/pre_execution.js e i moduli ESM e stream, per determinare dove gli stack trace possono essere ignorati in sicurezza. Il lavoro è completato quando le posizioni sicure sono state identificate e validate senza modificare i casi che richiedono il trace.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
I saw this library https://github.com/isaacs/catcher and I decided to wrote a benchmark:
Doing some changes on bench/error.js, the result was:
| name | ops/sec | samples |
|---|---|---|
| Error | 337,720 | 64 |
| Error (stackTraceLimit=0) | 3,284,296 | 94 |
| NodeError | 283,026 | 99 |
| NodeError (stackTraceLimit=0) | 3,280,933 | 95 |
| NodeError Range | 214,825 | 92 |
| NodeError Range (stackTraceLimit=0) | 3,313,990 | 99 |
Code
const { createBenchmarkSuite } = require('../common')
const suite = createBenchmarkSuite('Node.js Error')
suite
.add('Error', function () {
try {
new Error('test')
} catch (e) { }
})
.add('Error (stackTraceLimit=0)', function () {
const originalStackTraceLimit = Error.stackTraceLimit
Error.stackTraceLimit = 0
try {
new Error('test')
} catch (e) { }
finally {
Error.stackTraceLimit = originalStackTraceLimit;
}
})
.add('NodeError', function () {
try {
new TypeError('test')
} catch (e) { }
})
.add('NodeError (stackTraceLimit=0)', function () {
const originalStackTraceLimit = Error.stackTraceLimit
Error.stackTraceLimit = 0
try {
new TypeError('test')
} catch (e) { }
finally {
Error.stackTraceLimit = originalStackTraceLimit;
}
})
.add('NodeError Range', function () {
try {
new RangeError('test')
} catch (e) { }
})
.add('NodeError Range (stackTraceLimit=0)', function () {
const originalStackTraceLimit = Error.stackTraceLimit
Error.stackTraceLimit = 0
try {
new RangeError('test')
} catch (e) { }
finally {
Error.stackTraceLimit = originalStackTraceLimit;
}
})
.run({ async: false })
Based on this assumption, maybe we can find places on Node where we can safely ignore the stackTraceLimit, using this search, I found some places:
- https://github.com/nodejs/node/blob/0899bee48c64c4c2c5e2827a1ae5524a08542741/lib/internal/process/pre_execution.js#L215
- https://github.com/nodejs/node/blob/0899bee48c64c4c2c5e2827a1ae5524a08542741/lib/internal/modules/esm/worker.js#L66
- https://github.com/nodejs/node/blob/0899bee48c64c4c2c5e2827a1ae5524a08542741/lib/assert.js#L263
- https://github.com/nodejs/node/blob/0899bee48c64c4c2c5e2827a1ae5524a08542741/lib/internal/repl/utils.js#L131
- https://github.com/nodejs/node/blob/0899bee48c64c4c2c5e2827a1ae5524a08542741/lib/internal/streams/compose.js#L213
- https://github.com/nodejs/node/blob/0899bee48c64c4c2c5e2827a1ae5524a08542741/lib/internal/url.js#L151
- https://github.com/nodejs/node/blob/0899bee48c64c4c2c5e2827a1ae5524a08542741/lib/events.js#L501
- https://github.com/nodejs/node/blob/0899bee48c64c4c2c5e2827a1ae5524a08542741/lib/internal/encoding.js#L509
- https://github.com/nodejs/node/blob/0899bee48c64c4c2c5e2827a1ae5524a08542741/lib/internal/modules/esm/translators.js#L74
- https://github.com/nodejs/node/blob/6557c1c9b1206a85bb7d8e7450e8c3a4cff7c84b/lib/internal/worker/io.js#L277
- https://github.com/nodejs/node/blob/6557c1c9b1206a85bb7d8e7450e8c3a4cff7c84b/lib/internal/util.js#L375
- https://github.com/nodejs/node/blob/6557c1c9b1206a85bb7d8e7450e8c3a4cff7c84b/lib/querystring.js#L479
- Lingua principale
- Shell
- Stelle
- 399
- Fork
- 11
- Merge medio
- 29m
- PR unite (30g)
- 1
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di nodejs/performance
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
nodejs/performance#195 · 1 commento · 1 reazione ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
nodejs/performance#194 · 5 commenti · 1 reazione ·
-
benchmark-needed
Difficoltà 4/5 3-5 giorni Idoneità per principianti 30/100
nodejs/performance#193 · 1 commento · 3 reazioni ·
-
Optimize TextEncoder::encode Apertamajor performance regression
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
nodejs/performance#192 · 33 commenti · 7 reazioni ·
-
good first issue
Difficoltà 4/5 3-5 giorni Idoneità per principianti 42/100
nodejs/performance#187 · 11 commenti ·
Tutte le issue di nodejs/performance
Issue simili
-
out-of-date
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 82/100
CachyOS/CachyOS-PKGBUILDS#1894 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
community-scripts/ProxmoxVE#17396 · 1 commento ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
mattpocock/skills#1099 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
-
Update Vish to 1.1.5 Apertapackage-update
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
oSoWoSo/vOid_Community_repOsitory#144 · 1 commento ·