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

logic error in error reporting on upsert failure #316

Open
eymiha opened this issue Oct 11, 2024 · 2 comments · Fixed by #319
Open

logic error in error reporting on upsert failure #316

eymiha opened this issue Oct 11, 2024 · 2 comments · Fixed by #319

Comments

@eymiha
Copy link

eymiha commented Oct 11, 2024

in 1.3.2, in os/upsert.js, at line 82,

...
const wrappedCallback = function (err, ret) {
  if (err || (ret && ret.insertedId)) {
    // Send any errors to afterInsert
    afterInsert(ret.insertedId, err)
  } else {
...

In the function, if err is truthy, ret may still be undefined. Control will flow into the afterInsert, but ret.insertedId will fail to dereference ret and throw it's own error.

At this point, we are blocked as we can't apply the error to the upsert that caused it. So just record it to the server console, I suppose...

...
const wrappedCallback = function (err, ret) {
  if (err) {
    if (ret && ret.insertedId) {
      // Send any errors to afterInsert
      afterInsert(ret.insertedId, err)
    } else {
      // unable to recover the id, we need to punt.
      console.error(err);
    }
  } else {
...

This error seems to be in all releases of the package. I can only suppose that the problem went unnoticed based on the relative rarity of upserts and the added rarity of problems when upserting.

Copy link

Thank you for submitting this issue!

We, the Members of Meteor Community Packages take every issue seriously.
Our goal is to provide long-term lifecycles for packages and keep up
with the newest changes in Meteor and the overall NodeJs/JavaScript ecosystem.

However, we contribute to these packages mostly in our free time.
Therefore, we can't guarantee you issues to be solved within certain time.

If you think this issue is trivial to solve, don't hesitate to submit
a pull request, too! We will accompany you in the process with reviews and hints
on how to get development set up.

Please also consider sponsoring the maintainers of the package.
If you don't know who is currently maintaining this package, just leave a comment
and we'll let you know.

@eymiha eymiha changed the title logic error in error reporting on upsert failue logic error in error reporting on upsert failure Oct 11, 2024
@jankapunkt jankapunkt linked a pull request Nov 21, 2024 that will close this issue
@jankapunkt
Copy link
Member

Attempted fix is in tun pipeline: #319

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

Successfully merging a pull request may close this issue.

2 participants