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

Using logOptions with the defaultWriteDeleteCallback causes a crash. #71

Open
MoamenQodeup opened this issue Sep 23, 2024 · 3 comments
Open

Comments

@MoamenQodeup
Copy link

Describe the bug
Process crashed with error

node:internal/worker:266
    this[kPort].postMessage({
                ^
DOMException [DataCloneError]: (error) => {
                        if (error) {
                            console.error("failed to write to...<omitted>... } could not be cloned.
    at new DOMException (node:internal/per_context/domexception:53:5)
    at new Worker (node:internal/worker:266:17)
    at createWorker (/app/node_modules/.pnpm/thread-stream@2.7.0/node_modules/thread-stream/index.js:55:18)
    at new ThreadStream (/app/node_modules/.pnpm/thread-stream@2.7.0/node_modules/thread-stream/index.js:230:19)
    at buildStream (/app/node_modules/.pnpm/pino@8.21.0/node_modules/pino/lib/transport.js:21:18)
    at transport (/app/node_modules/.pnpm/pino@8.21.0/node_modules/pino/lib/transport.js:116:10)
    at normalizeArgs (/app/node_modules/.pnpm/pino@8.21.0/node_modules/pino/lib/tools.js:316:16)
    at pino (/app/node_modules/.pnpm/pino@8.21.0/node_modules/pino/pino.js:90:28)

To Reproduce

setting log options

 logOptions: {
          defaultWriteDeleteCallback: (error: unknown) => {
            if (error) {
              console.error("failed to write to Google Cloud Logging", { error });
            }
          },
        } as unknown as CloudPineOptions["cloudLoggingOptions"]["logOptions"],

Expected behavior
Passing logOptions with defaultWriteDeleteCallback should work

Additional context
The failure happens before invoking CloudPine contructor.

@metcoder95
Copy link
Owner

Hmm, this is hard; the error is somehow expected, functions/methods cannot be transferred between Worker Threads due to serialization. For instance, structuredClone algorithm throws as expected.

I believe that sadly we would need to drop that function unless we found a workaround

@MoamenQodeup
Copy link
Author

MoamenQodeup commented Sep 24, 2024

Hmm, this is hard; the error is somehow expected, functions/methods cannot be transferred between Worker Threads due to serialization. For instance, structuredClone algorithm throws as expected.

I believe that sadly we would need to drop that function unless we found a workaround

Thanks for taking the time checking this one, I believe I will have to fork the repo and integrate the handling directly into it.

@metcoder95
Copy link
Owner

If you find a way to extend it, please feel free to submit a PR for it do add it into the lib. Happy to support for that 👍

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

No branches or pull requests

2 participants