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

[ftr/asyncInstance] fix error thrown for undefined provider instances #22689

Merged
merged 1 commit into from
Sep 4, 2018

Conversation

spalger
Copy link
Contributor

@spalger spalger commented Sep 4, 2018

When a FTR service is created async the promise created by its provider is wrapped in a Proxy that checks before each property access if the instance has finished initializing. This breaks if the service provider returns undefined, which is the case for the failureDebugging service, because our truthy check will fail and we throw the error claiming the service is uninitialized, which is probably incorrect.

This PR updates the proxy to use a Symbol to indicate when a service instance is not available yet and throws a different error when the proxy receives any request (get, set, etc.) and the service instance is not an object, as required by the Reflect APIs.

@spalger spalger added review Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc v7.0.0 v6.5.0 labels Sep 4, 2018
@stacey-gammon
Copy link
Contributor

Much better:

          │         Service `failureDebugging.logBrowserConsole` is not supported because failureDebugging is undefined

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@spalger spalger merged commit 5baa6d5 into elastic:master Sep 4, 2018
spalger pushed a commit to spalger/kibana that referenced this pull request Sep 4, 2018
…elastic#22689)

When a FTR service is created async the promise created by its provider is wrapped in a [`Proxy`](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Proxy) that checks before each property access if the instance has finished initializing. This breaks if the service provider returns undefined, which is the case for the `failureDebugging` service, because our truthy check will fail and we throw the error claiming the service is uninitialized, which is probably incorrect.

This PR updates the proxy to use a `Symbol` to indicate when a service instance is not available yet and throws a different error when the proxy receives any request (get, set, etc.) and the service instance is not an object, as required by the Reflect APIs.
spalger pushed a commit that referenced this pull request Sep 5, 2018
…tances (#22689) (#22698)

Backports the following commits to 6.x:
 - [ftr/asyncInstance] fix error thrown for undefined provider instances  (#22689)
@spalger
Copy link
Contributor Author

spalger commented Sep 5, 2018

6.x/6.5: e6d036e

@spalger spalger deleted the fix/ftr-async-init-undefined-error branch September 5, 2018 00:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
review Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc v6.5.0 v7.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants