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

[BUG] Error when tracing (some) objects #27602

Closed
1 task done
martin-element22 opened this issue Oct 13, 2023 · 0 comments · Fixed by #27644
Closed
1 task done

[BUG] Error when tracing (some) objects #27602

martin-element22 opened this issue Oct 13, 2023 · 0 comments · Fixed by #27644
Assignees
Labels

Comments

@martin-element22
Copy link

martin-element22 commented Oct 13, 2023

System info

  • Playwright Version: [v1.39.0]
  • Operating System: [All]
  • Browser: [All]
  • Other info:

Source code

  • I provided exact source code that allows reproducing the issue locally.

Link to the GitHub repository with the repro

I could not get it to work without an extra dependency.

[BUG] Error when tracing (some) objects

Expected
When sending an ObjectId (tested with mongoose 6.7.0) in a request with tracing 'on', I expect the request to be sent.

Actual

When sending an ObjectId (tested with mongoose 6.7.0) in a request with tracing 'on', the request fail because of a crash when tracing the ObjectId.

Cause of the crash:

  • An ObjectId gets copied by visitTraceEvent. The toJSON gets copied but not all the attributes it depends on.
  • _appendTraceEvent try to stringify the value.
  • It crashes during ObjectId.toJSON.
TypeError: Cannot read properties of undefined (reading 'toString')
        at ObjectId.toHexString (C:\Users\Martin\repro_playwright\node_modules\bson\src\objectid.ts:135:31)
        at ObjectId.toJSON (C:\Users\Martin\repro_playwright\node_modules\bson\src\objectid.ts:203:17)

It is likely that something weird is going on with the ObjectId class that could be fixed in the class definition. In fact, that seems to be the case since a more recent version of the library did not exhibit the crash. However, I'd argue that the tracing process should be more resilient to unknown code executed during JSON.stringify. Particularly since we are messing with the object during the copy.

Thank you for the library. It's great :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants