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

fix(pacmak): TypeError when operating with Worker threads #2550

Merged
merged 5 commits into from
Feb 9, 2021

Conversation

RomainMuller
Copy link
Contributor

This works around isaacs/node-graceful-fs#204, where graceful-fs
cannot be loaded from within Worker threads. Since the language
generators are loaded in worker threads whenever they are available,
they cannot use fs-extra which itself uses graceful-fs.

This is hopefully a temporary measure, until isaacs/node-graceful-fs#205
is merged & released.


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

This works around isaacs/node-graceful-fs#204, where `graceful-fs`
cannot be loaded from within `Worker` threads. Since the language
generators are loaded in worker threads whenever they are available,
they cannot use `fs-extra` which itself uses `graceful-fs`.

This is hopefully a temporary measure, until isaacs/node-graceful-fs#205
is merged & released.
@RomainMuller RomainMuller requested a review from a team February 8, 2021 11:27
@mergify mergify bot added the contribution/core This is a PR that came from AWS. label Feb 8, 2021
@RomainMuller RomainMuller self-assigned this Feb 8, 2021
@RomainMuller RomainMuller added the bug This issue is a bug. label Feb 8, 2021
@@ -46,8 +46,16 @@ export class Golang extends Target {

// delete local.go.mod and local.go.sum from the output directory so it doesn't get published
const localGoSum = `${path.basename(localGoMod, '.mod')}.sum`;
await fs.remove(path.join(pkgDir, localGoMod));
await fs.remove(path.join(pkgDir, localGoSum));
await fs.unlink(path.join(pkgDir, localGoMod)).catch((err) =>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please extract to a helper function

visit(dep),
),
),
).then(() => void undefined);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not use await?

Copy link
Contributor Author

@RomainMuller RomainMuller Feb 8, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yeah you're right :P I thought I had... uh... a reason. but not.

const lines = (await fs.readFile(goMod, 'utf-8')).split('\n');
const lines = await fs
.readFile(goMod, 'utf8')
.then((text) => text.split('\n'));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this handle errors properly?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep - .then has no catch handler, so it'd simply use the original rejection.

await unlink(path.join(pkgDir, localGoMod));
await unlink(path.join(pkgDir, localGoSum));

async function unlink(file: string): Promise<void> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move outside

@mergify
Copy link
Contributor

mergify bot commented Feb 9, 2021

Thank you for contributing! ❤️ I will now look into making sure the PR is up-to-date, then proceed to try and merge it!

@mergify mergify bot added the pr/ready-to-merge This PR is ready to be merged. label Feb 9, 2021
@mergify
Copy link
Contributor

mergify bot commented Feb 9, 2021

Merging (with squash)...

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject89A8053A-6Jw05QLuWWwe
  • Commit ID: a1a5a26
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@mergify mergify bot merged commit 5822e48 into main Feb 9, 2021
@mergify mergify bot deleted the rmuller/fix-graceful-fs branch February 9, 2021 13:23
@mergify
Copy link
Contributor

mergify bot commented Feb 9, 2021

Merging (with squash)...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. contribution/core This is a PR that came from AWS.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants