Polis: User.createDummyUser undefined, preventing xid embed

Created on 15 Apr 2021  ·  10Comments  ·  Source: compdemocracy/polis

Expected behavior:
Polis embeds should be able to use xid-data in the

Actual behavior:
User creation fails with the following error message:

polis-server            | authtype doXidConversationIdAuth
polis-server            | no xInfo yet
polis-server            | TypeError: User.createDummyUser is not a function
polis-server            |     at /app/src/conversation.js:58:21
polis-server            | (node:1) Warning: Accessing non-existent property 'createDummyUser' of module exports inside circular dependency
polis-server            | TypeError: User.createDummyUser is not a function
polis-server            |     at /app/src/conversation.js:58:21
polis-server            | From previous event:
polis-server            |     at doAuth (/app/src/server.js:840:14)
polis-server            |     at /app/src/server.js:924:7
polis-server            |     at callbacks (/app/node_modules/express/lib/router/index.js:164:37)
polis-server            |     at param (/app/node_modules/express/lib/router/index.js:138:11)
polis-server            |     at pass (/app/node_modules/express/lib/router/index.js:145:5)
polis-server            |     at nextRoute (/app/node_modules/express/lib/router/index.js:100:7)
polis-server            |     at callbacks (/app/node_modules/express/lib/router/index.js:167:11)
polis-server            |     at middleware_check_if_options (/app/src/server.js:11864:14)
polis-server            |     at callbacks (/app/node_modules/express/lib/router/index.js:164:37)
polis-server            |     at param (/app/node_modules/express/lib/router/index.js:138:11)
polis-server            |     at pass (/app/node_modules/express/lib/router/index.js:145:5)
polis-server            |     at nextRoute (/app/node_modules/express/lib/router/index.js:100:7)
polis-server            |     at callbacks (/app/node_modules/express/lib/router/index.js:167:11)
polis-server            |     at addCorsHeader (/app/src/server.js:1128:12)
polis-server            |     at callbacks (/app/node_modules/express/lib/router/index.js:164:37)
polis-server            |     at param (/app/node_modules/express/lib/router/index.js:138:11)
polis-server            |     at pass (/app/node_modules/express/lib/router/index.js:145:5)
polis-server            |     at Router._dispatch (/app/node_modules/express/lib/router/index.js:173:5)
polis-server            |     at Object.router [as handle] (/app/node_modules/express/lib/router/index.js:33:10)
polis-server            | TypeError: User.createDummyUser is not a function
polis-server            |     at /app/src/conversation.js:58:21
polis-server            | From previous event:
polis-server            |     at doAuth (/app/src/server.js:840:14)
polis-server            |     at /app/src/server.js:924:7
polis-server            |     at callbacks (/app/node_modules/express/lib/router/index.js:164:37)
polis-server            |     at param (/app/node_modules/express/lib/router/index.js:138:11)
polis-server            |     at pass (/app/node_modules/express/lib/router/index.js:145:5)
polis-server            |     at nextRoute (/app/node_modules/express/lib/router/index.js:100:7)
polis-server            |     at callbacks (/app/node_modules/express/lib/router/index.js:167:11)
polis-server            |     at middleware_check_if_options (/app/src/server.js:11864:14)
polis-server            |     at callbacks (/app/node_modules/express/lib/router/index.js:164:37)
polis-server            |     at param (/app/node_modules/express/lib/router/index.js:138:11)
polis-server            |     at pass (/app/node_modules/express/lib/router/index.js:145:5)
polis-server            |     at nextRoute (/app/node_modules/express/lib/router/index.js:100:7)
polis-server            |     at callbacks (/app/node_modules/express/lib/router/index.js:167:11)
polis-server            |     at addCorsHeader (/app/src/server.js:1128:12)
polis-server            |     at callbacks (/app/node_modules/express/lib/router/index.js:164:37)
polis-server            |     at param (/app/node_modules/express/lib/router/index.js:138:11)
polis-server            |     at pass (/app/node_modules/express/lib/router/index.js:145:5)
polis-server            |     at Router._dispatch (/app/node_modules/express/lib/router/index.js:173:5)
polis-server            |     at Object.router [as handle] (/app/node_modules/express/lib/router/index.js:33:10)

To Reproduce:
I believe this is off of a more or less standard docker-compose setup.

Additional context:
This may be related to the following issue, but the error messages don't line up exactly: https://github.com/compdemocracy/polis/issues/287

Would be good to review that thread in greater detail to make sure we're not missing something (there might be a PR that hasn't been merged in yet).

The Warning: Accessing non-existent property 'createDummyUser' of module exports inside circular dependency bit looks especially suspicious that this is some node issue with recursive requires. I thought node was supposed to hoist variables in such cases without issue, but maybe we've hit an edge case?

All 10 comments

Haven't seen this myself, but I believe this is what @joshsmith2 submitted a PR for here, so might be worth reviewing/merging that sucker first: https://github.com/compdemocracy/polis/pull/757

Hi, I'm Niels. This issue was created by Chris after I asked him a question over email.

I added the PR code to my local version. That did not solve my problem but it does change the error in the log:

olis-server            | authtype doXidConversationIdAuth
polis-server            | no xInfo yet
polis-server            | created dummy
polis-postgres          | 2021-04-19 11:54:19.280 UTC [777] ERROR:  there is no unique or exclusion constraint matching the ON CONFLICT specification
polis-postgres          | 2021-04-19 11:54:19.280 UTC [777] STATEMENT:  insert into xids (owner, uid, xid, x_profile_image_url, x_name, x_email) values ($1, $2, $3, $4, $5, $6) on conflict (owner, xid) do nothing;
polis-server            | Error: there is no unique or exclusion constraint matching the ON CONFLICT specification
polis-server            |     at module.exports.Client._emitResult (/app/node_modules/pg-native/index.js:173:26)
polis-server            |     at module.exports.Client._read (/app/node_modules/pg-native/index.js:215:31)
polis-server            |     at PQ.emit (events.js:315:20)
polis-server            |     at PQ.EventEmitter.emit (domain.js:486:12)
polis-server            |     at PQ.callbackTrampoline (internal/async_hooks.js:129:14) {
polis-server            |   severity: 'ERROR',
polis-server            |   code: '42P10',
polis-server            |   file: 'plancat.c',
polis-server            |   line: '832',
polis-server            |   routine: 'infer_arbiter_indexes'
polis-server            | }
polis-server            | Error: there is no unique or exclusion constraint matching the ON CONFLICT specification
polis-server            |     at module.exports.Client._emitResult (/app/node_modules/pg-native/index.js:173:26)
polis-server            |     at module.exports.Client._read (/app/node_modules/pg-native/index.js:215:31)
polis-server            |     at PQ.emit (events.js:315:20)
polis-server            |     at PQ.EventEmitter.emit (domain.js:486:12)
polis-server            |     at PQ.callbackTrampoline (internal/async_hooks.js:129:14)
polis-server            | From previous event:
polis-server            |     at doAuth (/app/src/server.js:843:14)
polis-server            |     at /app/src/server.js:927:7
polis-server            |     at callbacks (/app/node_modules/express/lib/router/index.js:164:37)
polis-server            |     at param (/app/node_modules/express/lib/router/index.js:138:11)
polis-server            |     at pass (/app/node_modules/express/lib/router/index.js:145:5)
polis-server            |     at nextRoute (/app/node_modules/express/lib/router/index.js:100:7)
polis-server            |     at callbacks (/app/node_modules/express/lib/router/index.js:167:11)
polis-server            |     at middleware_check_if_options (/app/src/server.js:11867:14)
polis-server            |     at callbacks (/app/node_modules/express/lib/router/index.js:164:37)
polis-server            |     at param (/app/node_modules/express/lib/router/index.js:138:11)
polis-server            |     at pass (/app/node_modules/express/lib/router/index.js:145:5)
polis-server            |     at nextRoute (/app/node_modules/express/lib/router/index.js:100:7)
polis-server            |     at callbacks (/app/node_modules/express/lib/router/index.js:167:11)
polis-server            |     at addCorsHeader (/app/src/server.js:1131:12)
polis-server            |     at callbacks (/app/node_modules/express/lib/router/index.js:164:37)
polis-server            |     at param (/app/node_modules/express/lib/router/index.js:138:11)
polis-server            |     at pass (/app/node_modules/express/lib/router/index.js:145:5)
polis-server            |     at Router._dispatch (/app/node_modules/express/lib/router/index.js:173:5)
polis-server            |     at Object.router [as handle] (/app/node_modules/express/lib/router/index.js:33:10) {
polis-server            |   severity: 'ERROR',
polis-server            |   code: '42P10',
polis-server            |   file: 'plancat.c',
polis-server            |   line: '832',
polis-server            |   routine: 'infer_arbiter_indexes'
polis-server            | }
polis-server            | Error: there is no unique or exclusion constraint matching the ON CONFLICT specification
polis-server            |     at module.exports.Client._emitResult (/app/node_modules/pg-native/index.js:173:26)
polis-server            |     at module.exports.Client._read (/app/node_modules/pg-native/index.js:215:31)
polis-server            |     at PQ.emit (events.js:315:20)
polis-server            |     at PQ.EventEmitter.emit (domain.js:486:12)
polis-server            |     at PQ.callbackTrampoline (internal/async_hooks.js:129:14)
polis-server            | From previous event:
polis-server            |     at doAuth (/app/src/server.js:843:14)
polis-server            |     at /app/src/server.js:927:7
polis-server            |     at callbacks (/app/node_modules/express/lib/router/index.js:164:37)
polis-server            |     at param (/app/node_modules/express/lib/router/index.js:138:11)
polis-server            |     at pass (/app/node_modules/express/lib/router/index.js:145:5)
polis-server            |     at nextRoute (/app/node_modules/express/lib/router/index.js:100:7)
polis-server            |     at callbacks (/app/node_modules/express/lib/router/index.js:167:11)
polis-server            |     at middleware_check_if_options (/app/src/server.js:11867:14)
polis-server            |     at callbacks (/app/node_modules/express/lib/router/index.js:164:37)
polis-server            |     at param (/app/node_modules/express/lib/router/index.js:138:11)
polis-server            |     at pass (/app/node_modules/express/lib/router/index.js:145:5)
polis-server            |     at nextRoute (/app/node_modules/express/lib/router/index.js:100:7)
polis-server            |     at callbacks (/app/node_modules/express/lib/router/index.js:167:11)
polis-server            |     at addCorsHeader (/app/src/server.js:1131:12)
polis-server            |     at callbacks (/app/node_modules/express/lib/router/index.js:164:37)
polis-server            |     at param (/app/node_modules/express/lib/router/index.js:138:11)
polis-server            |     at pass (/app/node_modules/express/lib/router/index.js:145:5)
polis-server            |     at Router._dispatch (/app/node_modules/express/lib/router/index.js:173:5)
polis-server            |     at Object.router [as handle] (/app/node_modules/express/lib/router/index.js:33:10)

Maybe that helps?

Hi! Nice to meet you. Glad you got one dealt with :) I think you're peeling back some errors that @joshsmith2 has worked through. This is perhaps the next one to apply #758 . Pls do update how it goes!

If it feels like the right place, feel free to drop updates in the above thread (or here if the other issue seems different). I'm going to close this for now, but def feel welcome to re-open @nlsvgtr :)

Hi all, this issue just started occurring on all of my pol.is embeds. I have had two sites up for months now that embed pol.is conversations using xid's, and I had no problems. As of this week, though, voting and commenting are both broken, with both triggering this error in the console:

"TypeError: User.createDummyUser is not a function
   at /app/src/conversation.js:58:21↵:

Is this an issue that's being worked on right now, or is there something I can do to fix this on my end?

My quick impression is that merging https://github.com/compdemocracy/polis/pull/757 and https://github.com/compdemocracy/polis/pull/970 might resolve this, though checking xid embed functionality is missing from e2e tests

A simple "does this crash" e2e test (stealing from e2e/cypress/integration/polis/client-participation/embeds.spec.js), might look like:

describe('Xids', () => {
  // This test requires overriding client-admin/embed.html with
  // e2e/cypress/fixtures/html/embeds.html
  const POLIS_DOMAIN = Cypress.config().baseUrl.replace('https://', '')
  const CONVO_DESCRIPTION = 'This is dummy description for embed tests.'
  const CONVO_TOPIC = 'Embed test topic'

  beforeEach(function () {
    cy.createConvo('moderator').then(() => {
      cy.seedComment('Seed statement 1', this.convoId)
      cy.get('[data-test-id="description"]').type(CONVO_DESCRIPTION).blur()
      cy.get('[data-test-id="topic"]').type(CONVO_TOPIC).blur()
    })
  })

  it('renders a default embed with xid', function () {
    cy.logout()
    cy.visit(`${Cypress.config().baseUrl}/embed.html?polisDomain=${POLIS_DOMAIN}&data-conversation_id=${this.convoId}&data-xid=foo`)
    cy.enter(`#polis_${this.convoId}`).then(cyframe => {
      cyframe().find('div[data-view-name="root"]').as('iframe')
      cyframe().find('#readReactView').as('vote-widget')
      cyframe().find('#comment_form_textarea').as('comment-widget')
      cyframe().find('#helpTextWelcome').as('vote-help')
      cyframe().find('.POLIS_HEADLINE').as('headline')
      cyframe().find('svg.svgCenter').as('footer-logo')
      cyframe().find('#vis_section').as('vis')
    })

    cy.get('@iframe').should('be.visible')
    cy.get('@vote-widget').should('be.visible')
    cy.get('@comment-widget').should('be.visible')
    cy.get('@vote-help').should('be.visible')
    cy.get('@headline').should('contain', CONVO_DESCRIPTION)
    cy.get('@footer-logo').should('be.visible')
    cy.get('@headline').should('contain', CONVO_TOPIC)
    // TODO add full votes to check this
    //cy.get('@vis').should('be.visible')
  })

EDIT: I believe it needs an upstream fix, so unfortunately not a self-serve sorta deal...!

Merging #757 and #970 did fix it for me.

thank you @patcon and @nlsvgtr !!

Hi, just checking in to see what the status is on merging #757 and #970. Still waiting on reviews / tests?

When I need a pol.is conversation on my site, I just have links to the pol.is domain instead of iframes at the moment. That works for now, but if anyone has updates or advice on other workarounds, let me know!

Thanks again for all your amazing work, everyone.

I don't think it needs anything else like tests, just review and merge of team. (I believe they're working on some other large maintenance tasks.) If this is urgent for RxC Voice, I'd suggest making a case via email 🙏

EDIT: Also, speaking up in open issues, as closed issues might not be the best place

Was this page helpful?
0 / 5 - 0 ratings