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 ws.Set(Timeout/Interval) panicking on float values #1608

Merged
merged 2 commits into from Aug 28, 2020

Conversation

mstoykov
Copy link
Collaborator

The issue is connected to dop251/goja#190 in the
sense that instead of the float to int conversation to result in either
error or a clamped float value, it results in a 0 int value which panics
the stdlib time package.

Changing the parameter for the timeout/interval to float both makes it
possible to take values such as 0.5, meaning half a ms, and also checks
if the value is positive so we can be certain that it won't panic k6.
If not this results in an exception in the script.

The issue is connected to dop251/goja#190 in the
sense that instead of the float to int conversation to result in either
error or a clamped float value, it results in a 0 int value which panics
the stdlib time package.

Changing the parameter for the timeout/interval to float both makes it
possible to take values such as 0.5, meaning half a ms, and also checks
if the value is positive so we can be certain that it won't panic k6.
If not this results in an exception in the script.
@mstoykov mstoykov requested review from imiric and na-- August 26, 2020 09:32
@codecov-commenter
Copy link

codecov-commenter commented Aug 26, 2020

Codecov Report

Merging #1608 into master will increase coverage by 0.07%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1608      +/-   ##
==========================================
+ Coverage   74.82%   74.89%   +0.07%     
==========================================
  Files         164      164              
  Lines       14035    14043       +8     
==========================================
+ Hits        10501    10518      +17     
+ Misses       3002     2993       -9     
  Partials      532      532              
Impacted Files Coverage Δ
js/modules/k6/ws/ws.go 82.54% <100.00%> (+0.52%) ⬆️
js/runner.go 83.73% <0.00%> (+0.69%) ⬆️
lib/executors.go 94.11% <0.00%> (+1.96%) ⬆️
lib/executor/vu_handle.go 98.19% <0.00%> (+4.50%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c68a4eb...04e25be. Read the comment docs.

@na-- na-- added this to the v0.28.0 milestone Aug 28, 2020
na--
na-- previously approved these changes Aug 28, 2020
@na--
Copy link
Member

na-- commented Aug 28, 2020

Added #1305 (comment) as a reminder to use floats everywhere, when we unify the duration part of the configuration mess

@mstoykov
Copy link
Collaborator Author

For the record, I didn't find another place where we use int instead of float

imiric
imiric previously approved these changes Aug 28, 2020
Copy link
Contributor

@imiric imiric left a comment

Choose a reason for hiding this comment

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

👍 though I'm not sure sub-ms values would be useful. :)

See how Node handles timers:

When delay is larger than 2147483647 or less than 1, the delay will be set to 1. Non-integer delays are truncated to an integer.

js/modules/k6/ws/ws.go Outdated Show resolved Hide resolved
Co-authored-by: Ivan Mirić <ivan@loadimpact.com>
@mstoykov mstoykov dismissed stale reviews from imiric and na-- via 04e25be August 28, 2020 08:18
@mstoykov mstoykov merged commit df3ad1b into master Aug 28, 2020
@mstoykov mstoykov deleted the fixFloatTimesInJS branch August 28, 2020 08:33
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.

None yet

4 participants