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

Correctly bind browserstackLocal this-context #5187

Merged

Conversation

ctavan
Copy link
Contributor

@ctavan ctavan commented Mar 31, 2020

browserstackLocal.start() tries to call this.addArgs(). However the
this-binding gets lost when just calling
promisify(this.browserstackLocal) so the this-binding has to be
restored manually. See:
https://github.com/browserstack/browserstack-local-nodejs/blob/d238484416e7ea6dfb51aede7d84d09339a8032a/lib/Local.js#L28-L31

Fixes #5186

I am unsure how to add a proper test for this bug since the whole launcher test suite entirely mocks the browserstack-local npm module. This is also why the bug doesn't become visible in the test suite. Any ideas how to test this?

Edit: I was able to build a reproduction test case:

image

Proposed changes

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update

Checklist

  • I have read the CONTRIBUTING doc
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)
  • I have added proper type definitions for new commands (if appropriate)

Further comments

Reviewers: @webdriverio/project-committers

@jsf-clabot
Copy link

jsf-clabot commented Mar 31, 2020

CLA assistant check
All committers have signed the CLA.

`browserstackLocal.start()` tries to call `this.addArgs()`. However the
`this`-binding gets lost when just calling
`promisify(this.browserstackLocal)` so the `this`-binding has to be
restored manually. See:
https://github.com/browserstack/browserstack-local-nodejs/blob/d238484416e7ea6dfb51aede7d84d09339a8032a/lib/Local.js#L28-L31

Fixes webdriverio#5186
@ctavan ctavan force-pushed the fix-browserstack-this-binding branch from a06e718 to 404cbc7 Compare March 31, 2020 21:51
Copy link
Member

@christian-bromann christian-bromann left a comment

Choose a reason for hiding this comment

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

👍 Thanks!

@christian-bromann christian-bromann added the PR: Bug Fix 🐛 PRs that contain bug fixes label Apr 1, 2020
@christian-bromann christian-bromann merged commit 77acd59 into webdriverio:master Apr 1, 2020
@ctavan ctavan deleted the fix-browserstack-this-binding branch April 1, 2020 07:31
ctavan added a commit to ctavan/webdriverio that referenced this pull request Apr 1, 2020
Very much like webdriverio#5187 the promisified server.listen method is lacking the
correct this-binding. This leads to the server effectively NOT listening
on the specified port.
christian-bromann pushed a commit that referenced this pull request Apr 2, 2020
Very much like #5187 the promisified server.listen method is lacking the
correct this-binding. This leads to the server effectively NOT listening
on the specified port.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR: Bug Fix 🐛 PRs that contain bug fixes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error in browserstack service(v6.0.6) while intiating browserstack local binary
3 participants