-
Notifications
You must be signed in to change notification settings - Fork 42
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
Implement Browser.on(event)
#268
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here are my suggestions.
@imiric, by the way, we don't return here even though the connection is closed: func (b *Browser) initEvents() error {
...
go func() {
for {
select {
case <-cancelCtx.Done():
return
case event := <-chHandler:
...
} else if event.typ == EventConnectionClose {
...
b.browserProc.didLoseConnection()
b.cancelFn()
// LOOK HERE: it makes sense to return here
}
}
}
}() This might be a bug (even though the next iteration will catch that the context is being closed). I wanted to let you know. |
Resolves: - #268 (comment) - #268 (comment) - #268 (comment)
As discussed here[1][2], sleep() was only used in order to test the Promise rejection scenario. Since pressing ^C currently doesn't trigger it, and we should have a Go integration test that simply cancels the context, this sleep() is not needed anymore. [1]: #268 (comment) [2]: #268 (comment)
118e9df
to
7f51f8a
Compare
Resolves: - #268 (comment) - #268 (comment) - #268 (comment)
As discussed here[1][2], sleep() was only used in order to test the Promise rejection scenario. Since pressing ^C currently doesn't trigger it, and we should have a Go integration test that simply cancels the context, this sleep() is not needed anymore. [1]: #268 (comment) [2]: #268 (comment)
2c62667
to
a0e8d14
Compare
c3b0dce
to
0eb8df4
Compare
0eb8df4
to
6f0dd9a
Compare
6f0dd9a
to
51de7f9
Compare
13986c3
to
5ccc80e
Compare
This ensures the WS connection is cleanly closed, so that we wait for and process EventConnectionClose. It should also minimize "close 1006 (abnormal closure): unexpected EOF" errors[1] on shutdown. [1]: https://community.k6.io/t/erro-0006-unexpected-eof-error-during-run-of-example-script/3136
The k6 context-based utils were deprecated[1], and will be removed in v0.38.0[2], so this attaches VU to the context so that its helper functions can be used instead. Right now it will only be used for RegisterCallback(), but we should move all other uses of it soon (mainly GetRuntime()). [1]: grafana/k6@335d99c [2]: grafana/k6#2385
5ccc80e
to
82a601f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice job.
This drops all usage of context-based getter functions (removed from k6 in [1]) in favor of methods attached to the VU instance passed to the extension. We attached this VU instance to the internal context in #268 to keep a similar API, but in the future this should be refactored to avoid the use of context. [1]: grafana/k6@64f17c7
This drops all usage of context-based getter functions (removed from k6 in [1]) in favor of methods attached to the VU instance passed to the extension. We attached this VU instance to the internal context in #268 to keep a similar API, but in the future this should be refactored to avoid the use of context. [1]: grafana/k6@64f17c7
- Add the tooltip to the emoji to descrive what it means. - If there is an issue open for the feature then link to it from the emoji. Resolves: #722 (comment)
This is an implementation of
Browser.on(event)
, using the recently released event loop support in k6. The only supported event isdisconnected
, so it can be used as an alternative toteardown()
.It also does a few minor fixes and refactors. See the commits for details.
Closes #95