Closed MastroLindus closed 4 years ago
Can you post the job code and package version?
Found that it seems to fail (for me) when the data
object doesn't exist in a job document. So in toolbelt.js
at
// second, patch the cached document if write is successful
if (update) {
this.document.data[key] = value
}
it throws an error saying that it could not write to undefined.
Here's the error:
TypeError: Cannot set property 'c8ad64f290f3c75f87414776' of undefined
at toolbelt.set (packages/msavin:sjobs/server/imports/actions/execute/toolbelt.js:26:4)
...
@msavin Realized that you haven't updated the docs to say that data
is a valid Jobs.run
config. When looking for it, I found that because of the line in generateJobDoc
data: function () {
data = {}
try {
data = input.config.data;
} catch (e) {
// https://www.youtube.com/watch?v=XpdpW0z9xnQ
}
return data;
}(),
the data
field is always set to undefined if it's not set in input.config
.
should be fixed in the newly published v4, please let me know if you have any issues
Jobs.register({ "test": function () { this.set("counter", 0); } });
this.set("counter", 0); fails with cannot set property 'counter' of undefined.
Edit: Both get and set fail. Sometimes they work,but when the job gets replicated after being successful, the next run fails . I guess that the problem is that the "data" field in the DB is not always populated, while the getter expects it