throw on reading undefined file path #1
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes building lighthouse in Node 15.
static-module
calls brfs when it encounters afs.readFileSync
(and the other read methods) with a stringfile
if the path can be statically determined orundefined
if the path is too dynamic to figure out.Previous to Node 15, when brfs then does
fs.createReadStream(file)
, iffile
isundefined
it would immediately throw,static-module
would catch the error, and the original code would be retained instead of replacing it with an inline string.Node 15 made a change to stream construction (nodejs/node#29656) that made stream construction lazier, and so the error comes later (when piping begins),
static-module
no longer catches the error, and everything fails instead of continuing.This is probably the simplest fix, still throwing if
file
is undefined, just explicitly now instead of relying onfs.createReadStream
throwing.