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

Object to primitive value error #616

Closed
taylordowns2000 opened this issue Feb 29, 2024 · 4 comments · Fixed by #618
Closed

Object to primitive value error #616

taylordowns2000 opened this issue Feb 29, 2024 · 4 comments · Fixed by #618
Assignees
Labels
bug Something isn't working

Comments

@taylordowns2000
Copy link
Member

When using salesforce's bulk() function via the CLI, we see a log (from here) that looks like this:

[Object: null prototype] {
  '$': [Object: null prototype] {
    xmlns: 'http://www.force.com/2009/06/asyncapi/dataload'
  },
  id: '751S9000002POfeIAG',
  jobId: '750S9000002C6tKIAS',
  state: 'Queued',
  createdDate: '2024-02-29T11:51:14.000Z',
  systemModstamp: '2024-02-29T11:51:14.000Z',
  numberRecordsProcessed: '0',
  numberRecordsFailed: '0',
  totalProcessingTime: '0',
  apiActiveProcessingTime: '0',
  apexProcessingTime: '0'
}

And when we use that same job code on app.openfn.org (via the ws-worker, logger, etc.) we see a crash with this message:

Run complete with status: crash
ExecutionError: Cannot convert object to primitive value

I wonder if, somehow, the logger or the runtime or the ws-worker is trying to convert this log to a string via Object.toString() but is unable because the "null prototype" object does not inherit the toString property.

cc @aleksa-krolls , @mtuchi , @josephjclark

@taylordowns2000 taylordowns2000 added the bug Something isn't working label Feb 29, 2024
@taylordowns2000 taylordowns2000 moved this to New Issues in v2 Feb 29, 2024
@josephjclark
Copy link
Collaborator

Yeah we've got a raft of problems serialising error objects, it's something I've been struggling with for a while. I find it hard to repro cases and error objects in Javascript are basically rubbish.

The basic problem I think is that the logger interferes with and sometimes tries to serialise error objects.

There's a couple of related examples in #612 #582

@taylordowns2000 taylordowns2000 moved this from New Issues to Ready in v2 Mar 1, 2024
@taylordowns2000
Copy link
Member Author

taylordowns2000 commented Mar 2, 2024

@stuartc , @josephjclark - are you guys aware of any workarounds or temporary fixes for this? The WaterAid is blocked until we find a way forward with the crash that happens after using bulk() (top of this issue) and I'm wondering if a change to the adaptor might allow us to side-step this deeper issue and move forward.

I have a draft PR here but I'm not certain it actually does what we want since I'm not able to test it in Lightning w/o some way of using local/non-NPM adaptors with Lightning.

@josephjclark
Copy link
Collaborator

I've just looked a bit closer and I see that it's not actually an error object. It's just an object being logged.

So my guess is that the worker is failing to serialize that object properly to send it out of the worker thread.

Options:

  1. Remove that log line from the adaptor
  2. Patch in some magic to the logger to serialize objects better (I have no idea what this means and it'll likely cause side effects)
  3. Patch in a fix to the worker so that whatever this object is gets serialised properly.

I think the first step is to repro this on my local machine, then I can try to work out what's up with the actual error object.

@taylordowns2000
Copy link
Member Author

Yeah it's the object.toString being called on some sort of special "null property" object. Google tells me this is a way of making an object that's just a map... no special JS object properties (like toString).

What if I stringify inside the adaptor for now? So the logger just logs a string?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants