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] Payload converter error can crash worker #1512

Open
ikonst opened this issue Sep 11, 2024 · 0 comments
Open

[Bug] Payload converter error can crash worker #1512

ikonst opened this issue Sep 11, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@ikonst
Copy link
Contributor

ikonst commented Sep 11, 2024

What are you really trying to do?

Use the EJSON payload converter to serialize all my payload (including error details) without risking my workers crashing.

Why? I'm using ApplicationError's details to marshal exceptions from activity to workflow. Sometimes due to our own bugs and inattentiveness, we'd try to pass arbitrary objects (non necessarily JSONfiable) as the "details".

Describe the bug

I've used the EJSON payload converter almost verbatim in my code. The converter throws an error when the payload cannot be converted (due to unknown type, cyclic JSON etc.):

throw new UnsupportedEjsonTypeError(
  `Can't run EJSON.stringify on this value: ${value}. Either convert it (or its properties) to EJSON-serializable values (see https://docs.meteor.com/api/ejson.html ), or create a custom data converter. EJSON.stringify error message: ${
    errorMessage(
      e,
    )
  }`,
  e as Error,
);

If this occurs when converting an activity's response, no harm done since this will be caught by the try-catch that's responsible for catching all of the activity's errors.

However, if this happens when encoding e.g. the details of an ApplicationError, this error will escape the Worker.run and effectively crash the worker.

Minimal Reproduction

From your activity:

const cyclic: any = {};
cyclic["self"] = cyclic;
throw ApplicationFailure.create({
  message: "some error",
  type: "SomeError",
  nonRetryable: true,
  details: [cyclic],
});

Environment/Versions

Version 1.9.3

@ikonst ikonst added the bug Something isn't working label Sep 11, 2024
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
None yet
Development

No branches or pull requests

1 participant