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

Server error #1380

Closed
metasoarous opened this issue Apr 15, 2022 · 1 comment
Closed

Server error #1380

metasoarous opened this issue Apr 15, 2022 · 1 comment

Comments

@metasoarous
Copy link
Member

metasoarous commented Apr 15, 2022

We are periodically getting the following error from the server on the dev branch:

TypeError: Cannot read property '11' of undefined
at finishWith304or404 (/app/dist/src/server.js:1589:38)
at /app/dist/src/server.js:1631:21 polis_err undefined
(node:15) UnhandledPromiseRejectionWarning: TypeError [ERR_INVALID_ARG_TYPE]: The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object. Received an instance of TypeError
at Function.from (buffer.js:333:9)
at new Buffer (buffer.js:289:17)
at ServerResponse.res.end (/app/node_modules/express/node_modules/compression/index.js:106:22)
at emitTheFailure (/app/dist/src/log.js:53:9)
at fail (/app/dist/src/log.js:39:5)
at /app/dist/src/server.js:1636:13
(node:15) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 430)

In certain cases (either seed comment submission or voting, don't remember which), we're getting something a bit longer like this:

TypeError: Cannot read property '11' of undefined
at finishWith304or404 (/app/dist/src/server.js:1589:38)
at /app/dist/src/server.js:1631:21
at tryCatcher (/app/node_modules/bluebird/js/release/util.js:16:23)
at Promise._settlePromiseFromHandler (/app/node_modules/bluebird/js/release/promise.js:512:31)
at Promise._settlePromise (/app/node_modules/bluebird/js/release/promise.js:569:18)
at Promise._settlePromiseCtx (/app/node_modules/bluebird/js/release/promise.js:606:10)
at Async._drainQueue (/app/node_modules/bluebird/js/release/async.js:138:12)
at Async._drainQueues (/app/node_modules/bluebird/js/release/async.js:143:10)
at Immediate.Async.drainQueues [as _onImmediate] (/app/node_modules/bluebird/js/release/async.js:17:14)
at processImmediate (internal/timers.js:461:21)
at process.topLevelDomainCallback (domain.js:138:15)
at process.callbackTrampoline (internal/async_hooks.js:127:14) polis_err undefined
onPossiblyUnhandledRejection
1
TypeError [ERR_INVALID_ARG_TYPE]: The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object. Received an instance of TypeError
at Function.from (buffer.js:333:9)
at new Buffer (buffer.js:289:17)
at ServerResponse.res.end (/app/node_modules/express/node_modules/compression/index.js:106:22)
at emitTheFailure (/app/dist/src/log.js:53:9)
at fail (/app/dist/src/log.js:39:5)
at /app/dist/src/server.js:1636:13
at tryCatcher (/app/node_modules/bluebird/js/release/util.js:16:23)
at Promise._settlePromiseFromHandler (/app/node_modules/bluebird/js/release/promise.js:512:31)
at Promise._settlePromise (/app/node_modules/bluebird/js/release/promise.js:569:18)
at Promise._settlePromise0 (/app/node_modules/bluebird/js/release/promise.js:614:10)
at Promise._settlePromises (/app/node_modules/bluebird/js/release/promise.js:689:18)
at Async._drainQueue (/app/node_modules/bluebird/js/release/async.js:133:16)
at Async._drainQueues (/app/node_modules/bluebird/js/release/async.js:143:10)
at Immediate.Async.drainQueues [as _onImmediate] (/app/node_modules/bluebird/js/release/async.js:17:14)
at processImmediate (internal/timers.js:461:21)
at process.topLevelDomainCallback (domain.js:138:15)
at process.callbackTrampoline (internal/async_hooks.js:127:14) {
code: 'ERR_INVALID_ARG_TYPE'
}
2
TypeError [ERR_INVALID_ARG_TYPE]: The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object. Received an instance of TypeError
at Function.from (buffer.js:333:9)
at new Buffer (buffer.js:289:17)
at ServerResponse.res.end (/app/node_modules/express/node_modules/compression/index.js:106:22)
at emitTheFailure (/app/dist/src/log.js:53:9)
at fail (/app/dist/src/log.js:39:5)
at /app/dist/src/server.js:1636:13
at tryCatcher (/app/node_modules/bluebird/js/release/util.js:16:23)
at Promise._settlePromiseFromHandler (/app/node_modules/bluebird/js/release/promise.js:512:31)
at Promise._settlePromise (/app/node_modules/bluebird/js/release/promise.js:569:18)
at Promise._settlePromise0 (/app/node_modules/bluebird/js/release/promise.js:614:10)
at Promise._settlePromises (/app/node_modules/bluebird/js/release/promise.js:689:18)
at Async._drainQueue (/app/node_modules/bluebird/js/release/async.js:133:16)
at Async._drainQueues (/app/node_modules/bluebird/js/release/async.js:143:10)
at Immediate.Async.drainQueues [as _onImmediate] (/app/node_modules/bluebird/js/release/async.js:17:14)
at processImmediate (internal/timers.js:461:21)
at process.topLevelDomainCallback (domain.js:138:15)
at process.callbackTrampoline (internal/async_hooks.js:127:14) {
code: 'ERR_INVALID_ARG_TYPE'
}
3
TypeError [ERR_INVALID_ARG_TYPE]: The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object. Received an instance of TypeError
at Function.from (buffer.js:333:9)
at new Buffer (buffer.js:289:17)
at ServerResponse.res.end (/app/node_modules/express/node_modules/compression/index.js:106:22)
at emitTheFailure (/app/dist/src/log.js:53:9)
at fail (/app/dist/src/log.js:39:5)
at /app/dist/src/server.js:1636:13
at tryCatcher (/app/node_modules/bluebird/js/release/util.js:16:23)
at Promise._settlePromiseFromHandler (/app/node_modules/bluebird/js/release/promise.js:512:31)
at Promise._settlePromise (/app/node_modules/bluebird/js/release/promise.js:569:18)
at Promise._settlePromise0 (/app/node_modules/bluebird/js/release/promise.js:614:10)
at Promise._settlePromises (/app/node_modules/bluebird/js/release/promise.js:689:18)
at Async._drainQueue (/app/node_modules/bluebird/js/release/async.js:133:16)
at Async._drainQueues (/app/node_modules/bluebird/js/release/async.js:143:10)
at Immediate.Async.drainQueues [as _onImmediate] (/app/node_modules/bluebird/js/release/async.js:17:14)
at processImmediate (internal/timers.js:461:21)
at process.topLevelDomainCallback (domain.js:138:15)
at process.callbackTrampoline (internal/async_hooks.js:127:14)
4
{"code":"ERR_INVALID_ARG_TYPE"}
6

I've verified that this does not seem to be happening on prod/main.

Nothing seems broken on this branch (votes are submitting correctly, viz showing, etc), but I'm hesitant to release without understanding what's going on here.

Complicating this is the fact that now that we're using typescript, the log lines don't match up with the source code (will raise separate issue for this).

@metasoarous
Copy link
Member Author

This seems to have been introduced in the typescript conversion (#1232):

https://github.com/compdemocracy/polis/blame/dev/server/src/server.ts#L2059

The line there tries to initialize the pcaResultsExistForZid object mapping, even though it's already been initialized prior to the definition of the handle_GET_math_pca2 function. This effectively nullifies the math result caching system.

It's worse than that though, because while I think the intent was let pcaResultsExistForZid = {};, what was committed was let pcaResultsExistForZid: {};. In plain old node JS, this is a syntax error. But in TS, this compiles as let pcaResultsExistForZid, leaving the variable undefined, and explaining the specific error we're looking at.

(from typescriptlang.org:)

image

I should have a fix for this inbound as part of #1301

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

1 participant