-
-
Notifications
You must be signed in to change notification settings - Fork 33.4k
Open
Description
There are a few places where code flows like this:
try {
// some code that produces `result` and can potentially throw
callback(null, result); // no error, return result
} catch(error) {
callback(error);
}
These are usually (if not always) bugs, because it wraps the callback
call itself in the try
block, and if that callback throws, it gets caught and called again, but this time with its own error
.
For example:
Lines 150 to 160 in 06fb007
try { this.processReadResult(this.#path, result); const dirent = ArrayPrototypeShift(this.#bufferedEntries); if (this.#options.recursive && dirent.isDirectory()) { this.readSyncRecursive(dirent); } callback(null, dirent); } catch (error) { callback(error); } }; node/lib/internal/streams/compose.js
Lines 153 to 161 in 06fb007
d._write = async function(chunk, encoding, callback) { try { await writer.ready; writer.write(chunk).catch(() => {}); callback(); } catch (err) { callback(err); } }; - fs: remove IIFE in glob #58418
Some of these bugs might be a
good first issue
Metadata
Metadata
Assignees
Labels
No labels