Trying to run my drizzle + bun server setup on railway

daniakash
HOBBY

9 months ago

The setup runs locally when I tried with Nixpacks but crashes when running with railway. Since the error information isn't very helpful, kinda blocked here :(

Error that I received:

container event container died

16 |   const rawTable = new PgTable(name, schema, baseName);

17 |   const builtColumns = Object.fromEntries(

18 |     Object.entries(columns).map(([name2, colBuilderBase]) => {

19 |       const colBuilder = colBuilderBase;

20 |       const column = colBuilder.build(rawTable);

21 |       rawTable[InlineForeignKeys].push(...colBuilder.buildForeignKeys(column, rawTable));

                    ^

TypeError: undefined is not an object (evaluating 'Y[jS].push')

      at /app/node_modules/drizzle-orm/pg-core/table.js:21:16

      at map (:1:11)

      at $w1 (/app/node_modules/drizzle-orm/pg-core/table.js:18:29)

Bun v1.1.20 (Linux x64)

My nixpacks config:

[phases.build]
cmds = ['bun install --frozen-lockfile', 'bun compile']

[start]
cmd = 'bun out/index.js'

The server is running on port 3000

View Deploy details

ⓘ Deployment information is only viewable by project members and Railway employees.

2 Replies

daniakash
HOBBY

9 months ago

Seems like running compile and executing the compiled output file out/index.js was the problem. Its working fine if I just run the source directly

My compile command:

import { autoload } from 'esbuild-plugin-autoload'

await Bun.build({
  entrypoints: ['src/index.ts'],
  target: 'bun',
  outdir: 'out',
  minify: true,
  sourcemap: 'linked',
  plugins: [
    autoload({
      directory: './src/routes',
    }),
  ],
})

await Bun.$`bun build --compile out/index.js --outfile out/server`

9 months ago

Sounds like you solved this?