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

onConsoleAPICalled panics if an argument in console.log is null #774

Open
nuarhu opened this issue Feb 10, 2023 · 4 comments
Open

onConsoleAPICalled panics if an argument in console.log is null #774

nuarhu opened this issue Feb 10, 2023 · 4 comments
Labels
bug Something isn't working user request Requested by the community

Comments

@nuarhu
Copy link

nuarhu commented Feb 10, 2023

Brief summary

Logging a dynamic variable with console.log that can be null (or undefined) results in a go panic.

xk6-browser version

k6 v0.42.0

OS

macOS Ventura 13.1 (go1.19.4, darwin/arm64)

Chrome version

109.0.5414.119

Docker version and image (if applicable)

No response

Steps to reproduce the problem

The relevant code in TypeScript seems to be for example:

const someVar: null | boolean = null // dynamically set
console.log('some log information', someVar)

image

Expected behaviour

Just don't panic when there is null.

Actual behaviour

Panic (see stack trace above)

@nuarhu nuarhu added the bug Something isn't working label Feb 10, 2023
@inancgumus
Copy link
Member

@nuarhu, thanks for reporting the issue; we'll take a look. In the meantime, could you share the whole TypeScript code?

@nuarhu
Copy link
Author

nuarhu commented Feb 10, 2023

@inancgumus

I'm not completely sure what you mean with "whole TypeScript code". The project itself would be a lot, and it's under NDA.
Here is the relevant React useEffect hook.

fullScreen can be null/undefined while this React component initializes, and this useEffect waits for it to change to either true or false.

  React.useEffect(() => {
    if (evtHandler && selCat && selColor) {
      console.log('>>>>>>>>>>> fullscreen change', fullScreen)
      const event = {
        // omitted
      }
      if (fullScreen) {
        evtHandler.fullscreenStart(event)
      } else if (visFullScreen === false) {
        evtHandler.fullscreenEnd(event)
      }
    }
  }, [evtHandler, selCat, selColor, fullScreen])

We have changed the code so that the console.log only runs whenever fullScreen is defined, and this panic does not occur anymore. This seems to prove that a console.log('something', null) (or undefined) leads to a panic in the go code.

@inancgumus inancgumus added the user request Requested by the community label Mar 23, 2023
@ankur22
Copy link
Collaborator

ankur22 commented May 11, 2023

@nuarhu this issue looks very similar to #793 and #777. We've marked those as resolved since #859 fixed the issue. Once we release v0.45.0 of k6 you should be able to test it against your website and see whether that fix also works for your case.

@inancgumus
Copy link
Member

Maybe related: #987.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working user request Requested by the community
Projects
None yet
Development

No branches or pull requests

3 participants