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

Large request payload crashing API #736

Open
seeARMS opened this issue Jan 24, 2024 · 2 comments
Open

Large request payload crashing API #736

seeARMS opened this issue Jan 24, 2024 · 2 comments
Assignees
Labels
api: logging Issues related to the googleapis/nodejs-logging-bunyan API. priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@seeARMS
Copy link

seeARMS commented Jan 24, 2024

I am having the exact same issue described here: #14

Throughout the codebase, occasionally (and accidentally) I am logging very large entries, and encountering an exception which crashes the server:

Error: 3 INVALID_ARGUMENT: Request payload size exceeds the limit: 10485760 bytes.
  File "/workspace/node_modules/@grpc/grpc-js/build/src/call.js", line 31, col 19, in callErrorFromStatus
    const error = new Error(message);
  File "/workspace/node_modules/@grpc/grpc-js/build/src/client.js", line 192, col 76, in Object.onReceiveStatus
    callProperties.callback((0, call_1.callErrorFromStatus)(status, /*callerStack*/ ''));
  File "/workspace/node_modules/@grpc/grpc-js/build/src/client-interceptors.js", line 360, col 141, in Object.onReceiveStatus
    '{snip} istener === null || listener === void 0 ? void 0 : listener.onReceiveStatus) === null || _b === void 0 ? void 0 : _b.call(listener, status);
  File "/workspace/node_modules/@grpc/grpc-js/build/src/client-interceptors.js", line 323, col 181, in Object.onReceiveStatus
    '{snip} ener === void 0 ? void 0 : interceptingListener.onReceiveStatus) === null || _b === void 0 ? void 0 : _b.call(interceptingListener, status);
  File "/workspace/node_modules/@grpc/grpc-js/build/src/resolving-call.js", line 94, col 78, in <anonymous>
    (_a = this.listener) === null || _a === void 0 ? void 0 : _a.onReceiveStatus(filteredStatus);
  File "node:internal/process/task_queues", line 77, col 11, in process.processTicksAndRejections

I am using the logging-bunyan Express middleware as follows:

  const { logger: gcpLogger, mw } = await lb.express.middleware({
    logName: "api-" + process.env.FLY_APP_NAME,
    level: "debug",
    defaultCallback: (err: any) => {
      try {
        if (err) {
          console.error("Error occured with logger.", err)
          Sentry.captureMessage(err, { level: "error" })
        }
      } catch (_err) {
        console.error("Error occured with logger in try/catch blog.", _err)
        Sentry.captureException(_err)
      }
      return true
    },

    // GCP should truncate the message down to 200kb.
    // See https://github.com/googleapis/nodejs-logging/pull/607.
    maxEntrySize: 200000,
  })

It doesn't look like I'm able to pass in the arguments to this middleware as per the solution described here: googleapis/gax-nodejs#157 (comment)

maxEntrySize also doesn't seem to properly truncate.

Ideally, I don't care as much about truncating; I just want to properly handle the exception and not crash the server whenever I inadvertently attempt to log a massive entry.

Environment details

  • OS: Linux
  • Node.js version: 18.18.2
  • npm version: 10.3.0
  • @google-cloud/logging-bunyan version: 4.2.2
@seeARMS seeARMS added priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. labels Jan 24, 2024
@product-auto-label product-auto-label bot added the api: logging Issues related to the googleapis/nodejs-logging-bunyan API. label Jan 24, 2024
@cindy-peng
Copy link
Contributor

Hi @seeARMS, are you still running into this issue? If the GRPC options didn't work for you, could you also share the parameters you set?

@seeARMS
Copy link
Author

seeARMS commented Apr 15, 2024

Hi @seeARMS, are you still running into this issue? If the GRPC options didn't work for you, could you also share the parameters you set?

Where do I set those gRPC options? I mentioned in the OP that I'm using the logging bunyan Express middleware and the gRPC options don't get passed down

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: logging Issues related to the googleapis/nodejs-logging-bunyan API. priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

No branches or pull requests

2 participants