Skip to content
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

Merged
merged 3 commits into from Oct 19, 2020
Merged

chore(agnostification): common/helper.ts #6515

merged 3 commits into from Oct 19, 2020

Conversation

jackfranklin
Copy link
Collaborator

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.

@google-cla google-cla bot added the cla: yes label Oct 15, 2020
if (!isNode && path) {
throw new Error('Cannot write to a path outside of Node.js environment.');
}

Copy link
Member

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 ifs 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...)

Copy link
Member

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

Copy link
Collaborator Author

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.
@@ -59,6 +59,8 @@ jobs:

- node_js: "12.16.3"
name: 'Browser tests: Linux/Chromium'
addons:
chrome: stable
Copy link
Collaborator Author

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

Copy link
Contributor

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 :)

Copy link
Collaborator Author

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",
Copy link
Collaborator Author

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!

@jackfranklin jackfranklin merged commit c2c2bb7 into main Oct 19, 2020
@jackfranklin jackfranklin deleted the helper-agnostic branch October 19, 2020 08:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants