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 nodejs resource functions (ie registerResource) to properly propagate errors #6644

Merged
merged 6 commits into from
Mar 31, 2021

Conversation

EvanBoyle
Copy link
Contributor

Fixes #6643

More detail in the issues above, but TLDR is that we were swallowing errors in registerResource. This change fixes prepareResource to set up reject handlers on ID and URN promises to appropriately propagate the errors.

@EvanBoyle
Copy link
Contributor Author

The original repro that lead me to discover this. Unforunately it takes ~5 mins to run and only fails ~80% of the time: #6645

@EvanBoyle EvanBoyle requested a review from pgavlin March 29, 2021 20:41
Copy link
Member

@pgavlin pgavlin left a comment

Choose a reason for hiding this comment

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

Can we set up a test for this using mocks? Throwing from within newResource should work, I think.

@EvanBoyle
Copy link
Contributor Author

@pgavlin wouldn't that just be testing the mocked registerResource implementation? If so that wouldn't really validate this fix.

I had a hard time coming up with a way to test this. The only repro I currently have is the one linked here #6645 and it takes 5 minutes to fail, and the failure is non-deterministic as it seems related to resource exhaustion at some layer.

@EvanBoyle
Copy link
Contributor Author

(the mocked registerResource impl does't call prepareResource which is the layer at which the fix was made)

@justinvp
Copy link
Member

(the mocked registerResource impl does't call prepareResource which is the layer at which the fix was made)

When using a mock, prepareResource should still be called...

The Resource constructor calls registerResource in runtime/resource.ts:

registerResource(this, t, name, custom, remote, urn => new DependencyResource(urn), props, opts);

registerResource in runtime/resource.ts calls prepareResource:

const resopAsync = prepareResource(label, res, custom, props, opts);

And then call's the monitor's registerResource (whether monitor is an actual gRPC monitor or a mock monitor):

(monitor as any).registerResource(req, (rpcErr: grpc.ServiceError, innerResponse: any) => {

@EvanBoyle
Copy link
Contributor Author

@justinvp ah, thanks for the pointer. I did forgot that this was mocking the monitor and not the exported calls in runtime. I'll work on getting these tests added.

@EvanBoyle
Copy link
Contributor Author

@pgavlin @justinvp added the test. please take another look.

Copy link
Member

@justinvp justinvp left a comment

Choose a reason for hiding this comment

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

Do we need to do something similar for the resolvers for all the other outputs in transferProperties?

sdk/nodejs/tests/runtime/props.spec.ts Show resolved Hide resolved
@EvanBoyle
Copy link
Contributor Author

Do we need to do something similar for the resolvers for all the other outputs in transferProperties?

This is a very good point. These are actually the most common outstanding promises that we see leaked, and that would make sense as we aren't properly rejecting them...

Fix incoming.

@komalali
Copy link
Member

komalali commented Mar 31, 2021

Huh, looks like the transferProperties changes are causing unhandled rejections in the tests now.

EDIT:
NVM it failed on #6561 - the stack traces in the node tests threw me off.

@EvanBoyle EvanBoyle merged commit d098f91 into master Mar 31, 2021
@pulumi-bot pulumi-bot deleted the evan/nodejsRuntimeErrors branch March 31, 2021 03:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[nodejs] registerResource errors failing to propagate
4 participants