Skip to content
This repository was archived by the owner on Dec 12, 2023. It is now read-only.
This repository was archived by the owner on Dec 12, 2023. It is now read-only.

nuxt-session requires DB connection when build/generate command is running #87

Open
@wolodev

Description

@wolodev

Environment

  • Operating System: Darwin
  • Node Version: v19.4.0
  • Nuxt Version: 3.7.0
  • CLI Version: 3.7.3
  • Nitro Version: 2.6.2
  • Package Manager: [email protected]
  • Builder: -
  • User Config: modules, ssr, nitro, session
  • Runtime Modules: @sidebase/[email protected]
  • Build Modules: -

(I tried it also with other node version, like 18 lts and the result is the same)

Reproduction

I used npx nuxi@latest init + created one page + added sidebase/nuxt-session + added session

Download: https://github.com/wolodek/nuxt-sidebase-reproduction
Run: npm run build or npm run generate

Describe the bug

When some prerendered routes are define din nuxt config nuxt-session is running on them and try to access the DB during the build/generate process. If DB is not available it shows error about db connection, if it is the whole process hangs and never exits.

Additional context

I could try to fix this by myself - I though of disabling the module during build phase, what do you think?

Logs

If DB is not available it shows error:
`(base) lukaszwolodkiewicz@ukaszs-MacBook-Pro build-hangs % npm run build

> build
> nuxt build

Nuxt 3.7.0 with Nitro 2.6.2                                                                                         17:20:45
ℹ Setting up sessions...                                                                              nuxt-session 17:20:46
ℹ Session API "patch, delete, get, post" endpoints registered at "/api/session"                       nuxt-session 17:20:46
✔ Session setup complete                                                                              nuxt-session 17:20:46
ℹ Building client...                                                                                               17:20:46
ℹ vite v4.4.9 building for production...                                                                           17:20:47
ℹ ✓ 108 modules transformed.                                                                                       17:20:47
ℹ .nuxt/dist/client/manifest.json                   2.03 kB │ gzip:  0.37 kB                                       17:20:47
ℹ .nuxt/dist/client/_nuxt/error-500.c5df6088.css    1.95 kB │ gzip:  0.74 kB                                       17:20:47
ℹ .nuxt/dist/client/_nuxt/error-404.7fc72018.css    3.63 kB │ gzip:  1.12 kB                                       17:20:47
ℹ .nuxt/dist/client/_nuxt/entry.3c4ebcd6.css       12.13 kB │ gzip:  2.49 kB                                       17:20:47
ℹ .nuxt/dist/client/_nuxt/index.37c3a8bc.js         0.15 kB │ gzip:  0.15 kB                                       17:20:47
ℹ .nuxt/dist/client/_nuxt/static.8359dc28.js        0.17 kB │ gzip:  0.16 kB                                       17:20:47
ℹ .nuxt/dist/client/_nuxt/error-500.d2b60266.js     1.88 kB │ gzip:  0.99 kB                                       17:20:47
ℹ .nuxt/dist/client/_nuxt/error-404.e2b443c0.js     6.53 kB │ gzip:  2.90 kB                                       17:20:47
ℹ .nuxt/dist/client/_nuxt/entry.d45bdd8b.js       223.39 kB │ gzip: 65.13 kB                                       17:20:47
ℹ ✓ built in 909ms                                                                                                 17:20:47
✔ Client built in 918ms                                                                                            17:20:47
ℹ Building server...                                                                                               17:20:47
ℹ vite v4.4.9 building SSR bundle for production...                                                                17:20:47
ℹ ✓ 56 modules transformed.                                                                                        17:20:48
ℹ .nuxt/dist/server/_nuxt/entry-styles.8755339a.mjs             0.08 kB                                            17:20:48
ℹ .nuxt/dist/server/_nuxt/error-404-styles.1e0dde27.mjs         0.15 kB                                            17:20:48
ℹ .nuxt/dist/server/_nuxt/error-500-styles.cf4b3e80.mjs         0.15 kB                                            17:20:48
ℹ .nuxt/dist/server/styles.mjs                                  0.46 kB                                            17:20:48
ℹ .nuxt/dist/server/_nuxt/index-020c7268.js                     0.88 kB │ map:   0.22 kB                           17:20:48
ℹ .nuxt/dist/server/_nuxt/static-d4135fa8.js                    0.90 kB │ map:   0.23 kB                           17:20:48
ℹ .nuxt/dist/server/_nuxt/island-renderer-38fe09c3.js           1.05 kB │ map:   1.40 kB                           17:20:48
ℹ .nuxt/dist/server/_nuxt/error-500-styles-1.mjs-8fa81fcc.js    2.17 kB │ map:   0.12 kB                           17:20:48
ℹ .nuxt/dist/server/_nuxt/error-500-5829f75d.js                 3.02 kB │ map:   3.77 kB                           17:20:48
ℹ .nuxt/dist/server/_nuxt/error-404-styles-1.mjs-e0837f4f.js    3.86 kB │ map:   0.12 kB                           17:20:48
ℹ .nuxt/dist/server/_nuxt/error-404-949cd62c.js                 9.69 kB │ map:  18.97 kB                           17:20:48
ℹ .nuxt/dist/server/_nuxt/entry-styles-1.mjs-8b8449e7.js       12.38 kB │ map:   0.11 kB                           17:20:48
ℹ .nuxt/dist/server/server.mjs                                127.08 kB │ map: 177.84 kB                           17:20:48
ℹ ✓ built in 452ms                                                                                                 17:20:48
✔ Server built in 459ms                                                                                            17:20:48
✔ Generated public .output/public                                                                            nitro 17:20:48
ℹ Initializing prerenderer                                                                                   nitro 17:20:48
ℹ Prerendering 1 routes                                                                                      nitro 17:20:48

 ERROR  [ioredis] Unhandled error event: Error: connect ECONNREFUSED 127.0.0.1:6379                                 17:20:48
    at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1495:16)


 ERROR  [ioredis] Unhandled error event: Error: connect ECONNREFUSED 127.0.0.1:6379                                 17:20:48
    at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1495:16)


 ERROR  [ioredis] Unhandled error event: Error: connect ECONNREFUSED 127.0.0.1:6379                                 17:20:48
    at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1495:16)


 ERROR  [ioredis] Unhandled error event: Error: connect ECONNREFUSED 127.0.0.1:6379                                 17:20:49
    at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1495:16)


 ERROR  [ioredis] Unhandled error event: Error: connect ECONNREFUSED 127.0.0.1:6379                                 17:20:49
    at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1495:16)


 ERROR  [ioredis] Unhandled error event: Error: connect ECONNREFUSED 127.0.0.1:6379                                 17:20:49
    at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1495:16)`
    
    If Db is available it bundle app properly but never exits the terminal process:
    `lukaszwolodkiewicz@ukaszs-MacBook-Pro build-hangs % npm run build

> build
> nuxt build

Nuxt 3.7.0 with Nitro 2.6.2                                                                                         17:23:42
ℹ Setting up sessions...                                                                              nuxt-session 17:23:42
ℹ Session API "patch, delete, get, post" endpoints registered at "/api/session"                       nuxt-session 17:23:42
✔ Session setup complete                                                                              nuxt-session 17:23:42
ℹ Building client...                                                                                               17:23:43
ℹ vite v4.4.9 building for production...                                                                           17:23:43
ℹ ✓ 108 modules transformed.                                                                                       17:23:44
ℹ .nuxt/dist/client/manifest.json                   2.03 kB │ gzip:  0.37 kB                                       17:23:44
ℹ .nuxt/dist/client/_nuxt/error-500.c5df6088.css    1.95 kB │ gzip:  0.74 kB                                       17:23:44
ℹ .nuxt/dist/client/_nuxt/error-404.7fc72018.css    3.63 kB │ gzip:  1.12 kB                                       17:23:44
ℹ .nuxt/dist/client/_nuxt/entry.3c4ebcd6.css       12.13 kB │ gzip:  2.49 kB                                       17:23:44
ℹ .nuxt/dist/client/_nuxt/index.37c3a8bc.js         0.15 kB │ gzip:  0.15 kB                                       17:23:44
ℹ .nuxt/dist/client/_nuxt/static.8359dc28.js        0.17 kB │ gzip:  0.16 kB                                       17:23:44
ℹ .nuxt/dist/client/_nuxt/error-500.d2b60266.js     1.88 kB │ gzip:  0.99 kB                                       17:23:44
ℹ .nuxt/dist/client/_nuxt/error-404.e2b443c0.js     6.53 kB │ gzip:  2.90 kB                                       17:23:44
ℹ .nuxt/dist/client/_nuxt/entry.d45bdd8b.js       223.39 kB │ gzip: 65.13 kB                                       17:23:44
ℹ ✓ built in 878ms                                                                                                 17:23:44
✔ Client built in 886ms                                                                                            17:23:44
ℹ Building server...                                                                                               17:23:44
ℹ vite v4.4.9 building SSR bundle for production...                                                                17:23:44
ℹ ✓ 56 modules transformed.                                                                                        17:23:45
ℹ .nuxt/dist/server/_nuxt/entry-styles.8755339a.mjs             0.08 kB                                            17:23:45
ℹ .nuxt/dist/server/_nuxt/error-500-styles.cf4b3e80.mjs         0.15 kB                                            17:23:45
ℹ .nuxt/dist/server/_nuxt/error-404-styles.1e0dde27.mjs         0.15 kB                                            17:23:45
ℹ .nuxt/dist/server/styles.mjs                                  0.46 kB                                            17:23:45
ℹ .nuxt/dist/server/_nuxt/index-020c7268.js                     0.88 kB │ map:   0.22 kB                           17:23:45
ℹ .nuxt/dist/server/_nuxt/static-d4135fa8.js                    0.90 kB │ map:   0.23 kB                           17:23:45
ℹ .nuxt/dist/server/_nuxt/island-renderer-38fe09c3.js           1.05 kB │ map:   1.40 kB                           17:23:45
ℹ .nuxt/dist/server/_nuxt/error-500-styles-1.mjs-8fa81fcc.js    2.17 kB │ map:   0.12 kB                           17:23:45
ℹ .nuxt/dist/server/_nuxt/error-500-5829f75d.js                 3.02 kB │ map:   3.77 kB                           17:23:45
ℹ .nuxt/dist/server/_nuxt/error-404-styles-1.mjs-e0837f4f.js    3.86 kB │ map:   0.12 kB                           17:23:45
ℹ .nuxt/dist/server/_nuxt/error-404-949cd62c.js                 9.69 kB │ map:  18.97 kB                           17:23:45
ℹ .nuxt/dist/server/_nuxt/entry-styles-1.mjs-8b8449e7.js       12.38 kB │ map:   0.11 kB                           17:23:45
ℹ .nuxt/dist/server/server.mjs                                127.08 kB │ map: 177.84 kB                           17:23:45
ℹ ✓ built in 449ms                                                                                                 17:23:45
✔ Server built in 454ms                                                                                            17:23:45
✔ Generated public .output/public                                                                            nitro 17:23:45
ℹ Initializing prerenderer                                                                                   nitro 17:23:45
ℹ Prerendering 1 routes                                                                                      nitro 17:23:45
  ├─ /static (33ms)                                                                                           nitro 17:23:45
ℹ Building Nitro Server (preset: node-server)                                                                nitro 17:23:45
✔ Nitro server built                                                                                         nitro 17:23:47
  ├─ .output/server/chunks/app/_nuxt/entry-styles.8755339a.mjs (12.4 kB) (2.61 kB gzip)
  ├─ .output/server/chunks/app/_nuxt/entry-styles.8755339a.mjs.map (312 B) (202 B gzip)
  ├─ .output/server/chunks/app/_nuxt/error-404-949cd62c.mjs (9.9 kB) (3.15 kB gzip)
  ├─ .output/server/chunks/app/_nuxt/error-404-949cd62c.mjs.map (8.03 kB) (1.97 kB gzip)
  ├─ .output/server/chunks/app/_nuxt/error-404-styles.1e0dde27.mjs (3.98 kB) (1.25 kB gzip)
  ├─ .output/server/chunks/app/_nuxt/error-404-styles.1e0dde27.mjs.map (346 B) (215 B gzip)
  ├─ .output/server/chunks/app/_nuxt/error-500-5829f75d.mjs (3.16 kB) (1.38 kB gzip)
  ├─ .output/server/chunks/app/_nuxt/error-500-5829f75d.mjs.map (1.69 kB) (600 B gzip)
  ├─ .output/server/chunks/app/_nuxt/error-500-styles.cf4b3e80.mjs (2.28 kB) (870 B gzip)
  ├─ .output/server/chunks/app/_nuxt/error-500-styles.cf4b3e80.mjs.map (346 B) (217 B gzip)
  ├─ .output/server/chunks/app/_nuxt/index-020c7268.mjs (1.1 kB) (500 B gzip)
  ├─ .output/server/chunks/app/_nuxt/index-020c7268.mjs.map (740 B) (351 B gzip)
  ├─ .output/server/chunks/app/_nuxt/island-renderer-38fe09c3.mjs (1.26 kB) (554 B gzip)
  ├─ .output/server/chunks/app/_nuxt/island-renderer-38fe09c3.mjs.map (902 B) (413 B gzip)
  ├─ .output/server/chunks/app/_nuxt/static-d4135fa8.mjs (1.11 kB) (508 B gzip)
  ├─ .output/server/chunks/app/_nuxt/static-d4135fa8.mjs.map (742 B) (352 B gzip)
  ├─ .output/server/chunks/app/client.manifest.mjs (3.08 kB) (517 B gzip)
  ├─ .output/server/chunks/app/client.manifest.mjs.map (2.58 kB) (447 B gzip)
  ├─ .output/server/chunks/app/server.mjs (130 kB) (24.7 kB gzip)
  ├─ .output/server/chunks/app/server.mjs.map (303 B) (207 B gzip)
  ├─ .output/server/chunks/app/styles.mjs (533 B) (269 B gzip)
  ├─ .output/server/chunks/app/styles.mjs.map (429 B) (216 B gzip)
  ├─ .output/server/chunks/error-500.mjs (4.26 kB) (1.82 kB gzip)
  ├─ .output/server/chunks/error-500.mjs.map (193 B) (157 B gzip)
  ├─ .output/server/chunks/handlers/renderer.mjs (13 kB) (4.1 kB gzip)
  ├─ .output/server/chunks/handlers/renderer.mjs.map (424 B) (225 B gzip)
  ├─ .output/server/chunks/multipart-parser.mjs (5.1 kB) (2.12 kB gzip)
  ├─ .output/server/chunks/multipart-parser.mjs.map (210 B) (167 B gzip)
  ├─ .output/server/chunks/nitro/node-server.mjs (276 kB) (70.4 kB gzip)
  ├─ .output/server/chunks/nitro/node-server.mjs.map (4.28 kB) (994 B gzip)
  ├─ .output/server/chunks/rollup/_virtual_spa-template.mjs (94 B) (100 B gzip)
  ├─ .output/server/chunks/rollup/_virtual_spa-template.mjs.map (112 B) (112 B gzip)
  ├─ .output/server/index.mjs (457 B) (230 B gzip)
  └─ .output/server/package.json (3.81 kB) (1.34 kB gzip)
Σ Total size: 6.5 MB (1.84 MB gzip)
✔ You can preview this build using node .output/server/index.mjs                                             nitro 17:23:47
`

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions