polis
polis copied to clipboard
ReferenceError: authorUid is not defined
Expected behavior: This issue pertains to opening an existing conversation, and is relevant to both participant and owner views.
Actual behavior: While conversations can be created fine and operate normally for a period of time*, I have noticed that sometimes after a participant submits a new comment then suddenly said conversation no longer opens in any view. Instead a 500 error is thrown returning the error "polis_err_get_participationInit2". Only the single conversation in use is affected, others continue to work fine.
~$ curl "https://<polisrooturl>/api/v3/participationInit?conversation_id=4s6wrjb9rn&pid=mypid&lang=acceptLang"
polis_err_get_participationInit2
On the server side, the following stacktrace is produced:
ReferenceError: authorUid is not defined
polis-server-1 | at /app/dist/src/server.js:9583:39
polis-server-1 | at Array.map (<anonymous>)
polis-server-1 | at getSocialParticipants (/app/dist/src/server.js:9577:52)
polis-server-1 | at /app/dist/src/server.js:10431:17
polis-server-1 | at processImmediate (internal/timers.js:461:21)
polis-server-1 | at process.topLevelDomainCallback (domain.js:138:15)
polis-server-1 | at process.callbackTrampoline (internal/async_hooks.js:127:14)
polis-server-1 | From previous event:
polis-server-1 | at doFamousQuery (/app/dist/src/server.js:10424:12)
polis-server-1 | at ifConv (/app/dist/src/server.js:6686:26)
polis-server-1 | at handle_GET_participationInit (/app/dist/src/server.js:6738:13)
polis-server-1 | at callbacks (/app/node_modules/express/lib/router/index.js:164:37)
polis-server-1 | at /app/dist/src/utils/parameter.js:459:13
polis-server-1 | at callbacks (/app/node_modules/express/lib/router/index.js:164:37)
polis-server-1 | at /app/dist/src/utils/parameter.js:150:13
polis-server-1 | at callbacks (/app/node_modules/express/lib/router/index.js:164:37)
polis-server-1 | at /app/dist/src/server.js:4380:17
polis-server-1 | polis_err_get_participationInit2
To Reproduce: I am still trying to come up with reproducible steps on our dev server, but as yet this is inconclusive other than it occurs sometimes after a participant submits a comment after which that conversation [and only that conversation] is broken.
Potential fix:
Interestingly, the following comments are present in the code at the location specified in the stacktrace [/app/dist/src/server.js:9583, or server/src/server.js:13206 in the raw repository source]:
// TODO investigate this one.
// TODO looks like a possible typo bug
// Cannot find name 'authorUid'. Did you mean 'authoruid'?ts(2552)
// server.ts(12486, 7): 'authoruid' is declared here.
// @ts-ignore
return "select " + Number(authorUid) + " as uid, 900 as priority";
Following the advice of the wise commenter, I have replaced authorUid with authoruid in the select statement, which seems to resolve the issue. Conversations which were previously broken by this bug now return to normal.
I'm still investigating the code itself to actually understand why it is only triggered after certain comment submissions, and then to check that no other regressions are introduced as a result.
Thanks for the bug report! Seems it's related to this line, which I think @micahstubbs flagged as a bug (via comment) when he was doing the big typescript conversion:
https://github.com/compdemocracy/polis/blob/f526a149437e032e0bca5acb6e75c3a6017e84fe/server/src/server.ts#L13198-L13207
My name shows up in the git-blame for commit 9a294140b, but it was def @micahstubbs work.
TANGENT: As mentioned elsewhere, my name is mistakenly attributing to that commit. I'll create an issue to see if that can be re-attributed to micah.
Resolved in https://github.com/compdemocracy/polis/pull/1628