New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore(agnostification): common/helper.ts #6515
Conversation
if (!isNode && path) { | ||
throw new Error('Cannot write to a path outside of Node.js environment.'); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't we do let fs;
and then fs = ...
inside one of the if
s here? (It seems fine to rely on Node.js' caching regardless, but if we can avoid it and simplify the code at the same time...)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant let fs
— updated comment to clarify
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 PTAL!
The `readProtocolStream` method uses `fs` only if you want to write to a file. So we gate at the start of the function and ensure that if we got given a path we are not in a Node environment. We then use `import('fs')` to lazily load fs. We have multiple calls but they will be cached so I don't believe that it's going to be a perf hit.
ded9c0f
to
fe8f6cf
Compare
@@ -59,6 +59,8 @@ jobs: | |||
|
|||
- node_js: "12.16.3" | |||
name: 'Browser tests: Linux/Chromium' | |||
addons: | |||
chrome: stable |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
needed to ensure Travis has an up to date chrome that web test runner can use
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could also point it to the bundled chromium which puppeteer already brings. Let me know if I can help here :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@LarsDenBakker thanks! I'm quite keen to see if it's stable on a regular Chrome, but if not we'll reach for that and I expect I'll ping you for help :D
@@ -74,7 +74,7 @@ | |||
"@types/ws": "^7.2.4", | |||
"@typescript-eslint/eslint-plugin": "^4.4.0", | |||
"@typescript-eslint/parser": "^4.4.0", | |||
"@web/test-runner": "^0.8.4", | |||
"@web/test-runner": "^0.9.2", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the old version started timing out on CI...upgrading to this fixes it. Not entirely sure why!
The
readProtocolStream
method usesfs
only if you want to write to afile. So we gate at the start of the function and ensure that if we got
given a path we are not in a Node environment.
We then use
import('fs')
to lazily load fs. We have multiple calls butthey will be cached so I don't believe that it's going to be a perf hit.