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 null prototypes breaking the logger #618

Merged
merged 9 commits into from
Mar 4, 2024

Conversation

josephjclark
Copy link
Collaborator

This PR fixes an issue where an object with a null prototype causes the logger to blow up.

This in turn fixes bulk in the salesforce adaptor in the worker.

Related issue

Fixes #616

Implementation Details

The fundamental problem is is that this code throws an error:

const o = Object.create(null(
isNaN(o) // throws "cannot convert object to primitive value"

It just so happened that the Salesforce adaptor was triggering this exception because the logger calls isNaN on any console.logged values.

The fix is to do typeof x === 'number' instead, which feels much more robust for our purposes.

QA Notes

I've been testing on the SF sandbox with job:

bulk(
          'Contact',
          'insert',
          {
            failOnError: true,
            allowNoOp: true,
          },
          state => ([{
            "name": "testy mctestface",
            "email": "[email protected]"
          }])
        )

The same code is in a new unit test in ws-worker/test/worker.test.ts. I've disabled the test for CI but I think the pattern is useful to keep, so I'm keeping it.

Checklist before requesting a review

  • I have performed a self-review of my code
  • I have added unit tests
  • Changesets have been added (if there are production code changes)

Release branch checklist

Delete this section if this is not a release PR.

If this IS a release branch:

  • Run pnpm changeset from root to bump versions
  • Run pnpm install
  • Commit the new version numbers
  • Run pnpm changeset tag to generate tags
  • Push tags git push --tags

Tags may need updating if commits come in after the tags are first generated.

@josephjclark josephjclark marked this pull request as ready for review March 4, 2024 12:27
@taylordowns2000 taylordowns2000 merged commit 220afbd into main Mar 4, 2024
7 checks passed
@josephjclark josephjclark deleted the fix/616-serialize-errors branch March 4, 2024 15:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Object to primitive value error
2 participants