Skip to content

Error on gateway container when deploying in Google Cloud VM #1203

Closed

Description

@frolesti

What Happened?

I have followed all the steps on the Deployment guide (which maybe could use an update) with the latest main version. I am getting the following error when setting up the gateway container, which is preventing the complete deployment of the application:

root@alta-vm:/home/frolesti4_gmail_com/OpenDataCapture# docker logs open-data-capture-gateway-1
Server started at http://localhost:80
Server started at http://localhost:80
ReferenceError: document is not defined
    at Translator.changeLanguage (file:///app/dist/server/entry-server.js:31116:5)
    at Translator.replacementMethod (file:///app/dist/server/entry-server.js:31087:19)
    at Translator.init (file:///app/dist/server/entry-server.js:31130:10)
    at file:///app/dist/server/entry-server.js:107047:6
    at ModuleJob.run (node:internal/modules/esm/module_job:345:25)
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
    at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:665:26)
    at async file:///app/dist/main.js:74083:26
[01:06:48.611] ERROR (1): request errored
    req: "GET /"
    res: 500
    responseTime: 549
    err: {
      "type": "Error",
      "message": "failed with status code 500",
      "stack":
          Error: failed with status code 500
              at onResFinished (file:///app/dist/main.js:50710:46)
              at ServerResponse.onResponseComplete (file:///app/dist/main.js:50761:18)
              at ServerResponse.emit (node:events:531:35)
              at onFinish (node:_http_outgoing:1082:10)
              at callback (node:internal/streams/writable:766:21)
              at afterWrite (node:internal/streams/writable:710:5)
              at afterWriteTick (node:internal/streams/writable:696:10)
              at process.processTicksAndRejections (node:internal/process/task_queues:89:21)
    }
root@alta-vm:/home/frolesti4_gmail_com/OpenDataCapture# 

Is this something known? I am having a lot of issues with the deployment. I was able to deploy it two weeks ago with another version of main, something must have changed.

What Did You Expect?

I expect the gateway container to initiate properly

Operating System

Ubuntu 25.04

Browser (if applicable)

Chrome

Steps to Reproduce

No response

Anything Else?

No response

Activity

  1. added
    BugType: existing behavior is wrong
    on Oct 1, 2025
  2. joshunrau commented on Oct 1, 2025

    @joshunrau
    Collaborator

    Thanks for the report. I will have a look now.

  3. joshunrau commented on Oct 1, 2025

    @joshunrau
    Collaborator

    This issue should now be fixed in v1.11.2. It was due to a change in one of our libraries. Please update to that version.

  4. frolesti commented on Oct 1, 2025

    @frolesti
    Author

    Hi @joshunrau

    Thank you for your short response time, it is really appreciated. The thing is that I am still seeing the same error:

    [07:01:08.885] ERROR (1): request errored
        req: "GET //core/Datavase/.env"
        res: 500
        responseTime: 1
        err: {
          "type": "Error",
          "message": "failed with status code 500",
          "stack":
              Error: failed with status code 500
                  at onResFinished (file:///app/dist/main.js:50710:46)
                  at ServerResponse.onResponseComplete (file:///app/dist/main.js:50761:18)
                  at ServerResponse.emit (node:events:531:35)
                  at onFinish (node:_http_outgoing:1082:10)
                  at callback (node:internal/streams/writable:766:21)
                  at afterWrite (node:internal/streams/writable:710:5)
                  at afterWriteTick (node:internal/streams/writable:696:10)
                  at process.processTicksAndRejections (node:internal/process/task_queues:89:21)
        }
    ReferenceError: document is not defined
        at Translator.changeLanguage (file:///app/dist/server/entry-server.js:31116:5)
        at Translator.replacementMethod (file:///app/dist/server/entry-server.js:31087:19)
        at Translator.init (file:///app/dist/server/entry-server.js:31130:10)
        at file:///app/dist/server/entry-server.js:107047:6
        at ModuleJob.run (node:internal/modules/esm/module_job:345:25)
        at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
        at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:665:26)
        at async file:///app/dist/main.js:74083:26
    [07:01:09.153] ERROR (1): request errored
        req: "GET //database/.env"
        res: 500
        responseTime: 1
        err: {
          "type": "Error",
          "message": "failed with status code 500",
          "stack":
              Error: failed with status code 500
                  at onResFinished (file:///app/dist/main.js:50710:46)
                  at ServerResponse.onResponseComplete (file:///app/dist/main.js:50761:18)
                  at ServerResponse.emit (node:events:531:35)
                  at onFinish (node:_http_outgoing:1082:10)
                  at callback (node:internal/streams/writable:766:21)
                  at afterWrite (node:internal/streams/writable:710:5)
                  at afterWriteTick (node:internal/streams/writable:696:10)
                  at process.processTicksAndRejections (node:internal/process/task_queues:89:21)
        }
    ReferenceError: document is not defined
        at Translator.changeLanguage (file:///app/dist/server/entry-server.js:31116:5)
        at Translator.replacementMethod (file:///app/dist/server/entry-server.js:31087:19)
        at Translator.init (file:///app/dist/server/entry-server.js:31130:10)
        at file:///app/dist/server/entry-server.js:107047:6
        at ModuleJob.run (node:internal/modules/esm/module_job:345:25)
        at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
        at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:665:26)
        at async file:///app/dist/main.js:74083:26
    [07:01:09.410] ERROR (1): request errored
        req: "GET //config/.env"
        res: 500
        responseTime: 3
        err: {
          "type": "Error",
          "message": "failed with status code 500",
          "stack":
              Error: failed with status code 500
                  at onResFinished (file:///app/dist/main.js:50710:46)
                  at ServerResponse.onResponseComplete (file:///app/dist/main.js:50761:18)
                  at ServerResponse.emit (node:events:531:35)
                  at onFinish (node:_http_outgoing:1082:10)
                  at callback (node:internal/streams/writable:766:21)
                  at afterWrite (node:internal/streams/writable:710:5)
                  at afterWriteTick (node:internal/streams/writable:696:10)
                  at process.processTicksAndRejections (node:internal/process/task_queues:89:21)
        }
    ReferenceError: document is not defined
        at Translator.changeLanguage (file:///app/dist/server/entry-server.js:31116:5)
        at Translator.replacementMethod (file:///app/dist/server/entry-server.js:31087:19)
        at Translator.init (file:///app/dist/server/entry-server.js:31130:10)
        at file:///app/dist/server/entry-server.js:107047:6
        at ModuleJob.run (node:internal/modules/esm/module_job:345:25)
        at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
        at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:665:26)
        at async file:///app/dist/main.js:74083:26
    

    When setting up the containers, it looks like it is properly set. But then, eventually this error appears again.

  5. frolesti commented on Oct 1, 2025

    @frolesti
    Author

    I take it might be an issue of my set up?

    I changed the server Linux provider to Ubuntu 22.04 but to no use, I have been following the deployment guides so everything seems to be in place.

  6. gdevenyi commented on Oct 1, 2025

    @gdevenyi
    Contributor

    In order to provide better support here. Can you please describe the entirety of your setup process, this means:

    • your (anonymized) environment file
    • the exact commands you use to launch
    • the docker compose file

    Thanks.

  7. joshunrau commented on Oct 1, 2025

    @joshunrau
    Collaborator

    Could you please also confirm that the version is updated to 1.11.2. I replicated this issue on our demo and updating the version fixed it. Did you run docker compose down and then docker compose up -d. I don't think docker compose restart will use the latest images.

    GATEWAY_BASE_URL=
    curl $GATEWAY_BASE_URL/api/healthcheck | jq .release.version
  8. frolesti commented on Oct 1, 2025

    @frolesti
    Author

    Hi guys, thank you for your interest!

    This is my .env file:

    ## ---------------------------------
    ## PRODUCTION
    ## ---------------------------------
    
    # The domain name to use for your site in the production compose stack
    SITE_ADDRESS=myplatform.com
    # The domain name to use for the gateway service in the production compose stack
    GATEWAY_SITE_ADDRESS=http://gateway.myplatform.com
    
    # The ports to listen on
    APP_PORT=5500
    PLAYGROUND_PORT=3750
    GATEWAY_PORT=3500
    
    # The Docker release to use (latest = stable)
    RELEASE_CHANNEL=latest
    # The MongoDB version to use
    MONGODB_VERSION=7.0
    
    ## ---------------------------------
    ## PRODUCTION + DEVELOPMENT
    ## ---------------------------------
    
    # The absolute path to the root of the project (i.e., the directory where this file is located)
    PROJECT_ROOT=/home/frolesti4_gmail_com/OpenDataCapture
    
    # The value to use for various security purposes.
    SECRET_KEY=847dd5abadc2be1f1301f5f15a2c05579d74711f3880bcb18ecb88c0be3a6800
    
    # MongoDB URI not including database name. This will be overriden in production
    # by the value defined in docker-compose.yaml. If you are using a remote database in
    # development, you should set that here.
    MONGO_URI=mongodb://localhost:27017
    MONGO_REPLICA_SET=
    MONGO_RETRY_WRITES=
    MONGO_WRITE_CONCERN=
    MONGO_DIRECT_CONNECTION=
    
    # An email address to be used for mailto links on the website
    CONTACT_EMAIL=support@douglasneuroinformatics.ca
    # A link to the documentation page
    DOCS_URL=https://opendatacapture.org/docs
    # A link to the repository containing the source code for the platform
    GITHUB_REPO_URL=https://github.com/DouglasNeuroInformatics/OpenDataCapture
    # Whether or not the gateway should be activated
    GATEWAY_ENABLED=true
    # A link to the license governing distribution of the platform and all derivative work
    LICENSE_URL=https://www.apache.org/licenses/LICENSE-2.0
    # The interval (in miliseconds) at which the API will attempt to resync with the gateway
    GATEWAY_REFRESH_INTERVAL=10000
    # The path to the SQLite file for the gateway (e.g., file:/path/to/database.db)
    GATEWAY_DATABASE_URL=file:/home/frolesti4_gmail_com/OpenDataCapture/apps/gateway/data/gateway.db
    # The api key used internally in communication between the gateway and core API - minimum length of 32
    GATEWAY_API_KEY=7ecdd2acd73c65a6921d59a19faa6e12cd26c276a4f6dfdf09619bdfc8e259ec
    # Whether 'debug' level logs should be enabled
    DEBUG=false
    # Whether 'verbose' level logs should be enabled
    VERBOSE=false
    # Enable rate limitting
    THROTTLER_ENABLED=true
    # Disable iteration for password hashing (not recommended for production)
    # See https://pages.nist.gov/800-63-3/sp800-63b.html
    # DANGEROUSLY_DISABLE_PBKDF2_ITERATION=
    
    ## ---------------------------------
    ## DEVELOPMENT
    ## ---------------------------------
    
    # The port to use for the NestJS development server
    API_DEV_SERVER_PORT=5500
    # The port to use for the Astro (outreach website) development server
    OUTREACH_DEV_SERVER_PORT=4000
    # The port for the playground
    PLAYGROUND_DEV_SERVER_PORT=3750
    # The port to use for the gateway development server
    GATEWAY_DEV_SERVER_PORT=3500
    # The port to use for the Vite (full web app) development server
    WEB_DEV_SERVER_PORT=3000
    # Set an arbitrary delay (in milliseconds) for all responses (useful for testing suspense)
    API_RESPONSE_DELAY=
    # If set to 'true' and NODE_ENV === 'development', then login is automated
    VITE_DEV_BYPASS_AUTH=false
    # The username to use if VITE_DEV_BYPASS_AUTH is set to true
    VITE_DEV_USERNAME=admin
    # The password to use if VITE_DEV_BYPASS_AUTH is set to true
    VITE_DEV_PASSWORD=Password12345678
    # The base url for requests, which is overridden by reverse proxy in compose stack
    API_BASE_URL=http://localhost:5500
    # The number of miliseconds to delay the result of HTTP requests in development
    VITE_DEV_NETWORK_LATENCY=0
    # Whether to force clear queries when the pathname changes
    VITE_DEV_FORCE_CLEAR_QUERY_CACHE=false
    # Whether to disable tutorial in dev mode
    VITE_DEV_DISABLE_TUTORIAL=false
    # Plausable analytics config (optional, set both to an empty string to disable)
    PLAUSIBLE_BASE_URL=
    PLAUSIBLE_WEB_DATA_DOMAIN=
    
    TURBO_CACHE_DIR=".turbo"
    
    
    
    This is the docker-compose.yaml file (untouched)
    
    name: open-data-capture
    volumes:
      caddy_data:
    services:
      caddy:
        image: caddy:2.7-alpine
        restart: unless-stopped
        ports:
          - ${APP_PORT}:80
        environment:
          - SITE_ADDRESS
        volumes:
          - ./Caddyfile:/etc/caddy/Caddyfile
          - caddy_data:/data
        profiles:
          - '' #load by default without having to specify docker compose --profile
          - gateway
          - fullstack
          - nogateway
      api:
        image: ghcr.io/douglasneuroinformatics/open-data-capture-api:${RELEASE_CHANNEL}
        build:
          context: .
          dockerfile: ./apps/api/Dockerfile
          args:
            - RELEASE_VERSION
        depends_on:
          - mongo
        restart: unless-stopped
        environment:
          - GATEWAY_INTERNAL_NETWORK_URL=http://gateway:80
          - MONGO_REPLICA_SET=rs0
          - MONGO_RETRY_WRITES=true
          - MONGO_WRITE_CONCERN=majority
          - MONGO_DIRECT_CONNECTION=true
          - MONGO_URI=mongodb://mongo:27017
          - NODE_ENV=production
          - DANGEROUSLY_DISABLE_PBKDF2_ITERATION
          - DEBUG
          - GATEWAY_API_KEY
          - GATEWAY_ENABLED
          - GATEWAY_REFRESH_INTERVAL
          - GATEWAY_SITE_ADDRESS
          - SECRET_KEY
          - THROTTLER_ENABLED
          - VERBOSE
        expose:
          - 80
        profiles:
          - '' #load by default without having to specify docker compose --profile
          - fullstack
          - nogateway
      gateway:
        image: ghcr.io/douglasneuroinformatics/open-data-capture-gateway:${RELEASE_CHANNEL}
        build:
          args:
            - RELEASE_VERSION
          context: .
          dockerfile: ./apps/gateway/Dockerfile
        ports:
          - ${GATEWAY_PORT}:80
        expose:
          - 80
        profiles:
          - '' #load by default without having to specify docker compose --profile
          - gateway
          - fullstack
        restart: unless-stopped
        environment:
          - NODE_ENV=production
          - GATEWAY_API_KEY
        volumes:
          - ./sqlite:/app/sqlite
      web:
        image: ghcr.io/douglasneuroinformatics/open-data-capture-web:${RELEASE_CHANNEL}
        build:
          args:
            - RELEASE_VERSION
          context: .
          dockerfile: ./apps/web/Dockerfile
        environment:
          - API_BASE_URL=/api
          - CONTACT_EMAIL
          - DOCS_URL
          - GITHUB_REPO_URL
          - LICENSE_URL
          - GATEWAY_ENABLED
          - PLAUSIBLE_BASE_URL
          - PLAUSIBLE_WEB_DATA_DOMAIN
        expose:
          - 80
        profiles:
          - '' #load by default without having to specify docker compose --profile
          - fullstack
          - nogateway
        restart: unless-stopped
      mongo:
        image: mongo:${MONGODB_VERSION}
        command: ['--replSet', 'rs0', '--bind_ip_all', '--port', '27017']
        expose:
          - 27017
        restart: unless-stopped
        healthcheck:
          test: echo "try { rs.status() } catch (err) { rs.initiate({_id:'rs0',members:[{_id:0,host:'localhost:27017'}]}) }" | mongosh --port 27017 --quiet
          interval: 5s
          timeout: 30s
          start_period: 0s
          start_interval: 1s
          retries: 30
        volumes:
          - ./mongo/config:/data/configdb
          - ./mongo/data:/data/db
        profiles:
          - '' #load by default without having to specify docker compose --profile
          - fullstack
          - nogateway
      playground:
        build:
          context: .
          dockerfile: ./apps/playground/Dockerfile
        environment:
          - NODE_ENV=production
        ports:
          - '3750:80'
        restart: unless-stopped
        profiles:
          - fullstack
          - playground
    

    This is my /etc/caddy/Caddyfile:

    {
      email my@mail.com 
    }
    
    myplatform.com {
      reverse_proxy localhost:5500
    }
    
    gateway.myplatform.com {
      reverse_proxy localhost:3500
    }
    

    I have been following the guide step by step. I set up a VM in Google Cloud, install Linux, Docker and Caddy. Then, I clone my forked repository, execute the generate-env script succesfully and change the .env to point into my domain. Then execute docker compose up -d. At first, it looks like the gateway is properly listening to the localhost:80 port, but eventually this error appears when executing docker logs open-data-capture-gateway-1.

    Is there anything I am missing?

  9. thomasbeaudry commented on Oct 2, 2025

    @thomasbeaudry
    Collaborator

    did you try doing a docker compose pull?

  10. gdevenyi commented on Jun 9, 2026

    @gdevenyi
    Contributor

    Triaging upstream: deployment/runtime versions have changed substantially since this issue was opened. Is this gateway startup error still reproducible on the current version in Google Cloud VM? If so, please add current logs and deployment details.

  11. joshunrau commented on Sep 16, 2026

    @joshunrau
    Collaborator

    Closing as irrelevant: the underlying SSR bug (document is not defined) was fixed in v1.11.2. The residual report traced to the reporter's stale deployment config (old compose format, missing services) rather than a defect in the current stack, and a maintainer already flagged this as likely stale with no reply since.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugType: existing behavior is wrong

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions