Skip to content

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

Merged
spalger merged 1 commit intoelastic:masterfrom
spalger:fix/ftr-async-init-undefined-error
Sep 4, 2018
Merged

[ftr/asyncInstance] fix error thrown for undefined provider instances#22689
spalger merged 1 commit intoelastic:masterfrom
spalger:fix/ftr-async-init-undefined-error

Conversation

@spalger
Copy link
Copy Markdown
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 Platform Core services: plugins, logging, config, saved objects, http, ES client, i18n, etc t// v7.0.0 v6.5.0 labels Sep 4, 2018
@stacey-gammon
Copy link
Copy Markdown

Much better:

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

@elasticmachine
Copy link
Copy Markdown
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
Copy Markdown
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 Platform Core services: plugins, logging, config, saved objects, http, ES client, i18n, etc t// v6.5.0 v7.0.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants