Retool Self Host error service backoffice-retool-main-service

Hi, you are installing Self-hosted Retool Service on AWS using Docker Compose with Terraform.

During the installation, errors were found in the service: tapi-dev-backoffice-retool-main-service

Log:

message
not untarring the bundle
sed: can't read ./dist/mobile/.js: No such file or directory
{"level":"info","message":"[process service types] JOBS_RUNNER","timestamp":"2024-05-28T14:13:24.597Z"}
'"---------------------------"
'"- EXITING RETOOL -"
'"---------------------------"
Error running database migrations: TypeError: Cannot read properties of undefined (reading 'use_env_variable')
not untarring the bundle
sed: can't read ./dist/mobile/
.js: No such file or directory
{"level":"info","message":"[process service types] JOBS_RUNNER","timestamp":"2024-05-28T14:15:41.770Z"}
'"---------------------------"
'"- EXITING RETOOL -"
'"---------------------------"
Error running database migrations: TypeError: Cannot read properties of undefined (reading 'use_env_variable')
not untarring the bundle
sed: can't read ./dist/mobile/.js: No such file or directory
{"level":"info","message":"[process service types] JOBS_RUNNER","timestamp":"2024-05-28T14:18:17.305Z"}
'"---------------------------"
'"- EXITING RETOOL -"
'"---------------------------"
Error running database migrations: TypeError: Cannot read properties of undefined (reading 'use_env_variable')
not untarring the bundle
sed: can't read ./dist/mobile/
.js: No such file or directory
{"level":"info","message":"[process service types] JOBS_RUNNER","timestamp":"2024-05-28T14:20:43.702Z"}
'"---------------------------"
'"- EXITING RETOOL -"
'"---------------------------"
Error running database migrations: TypeError: Cannot read properties of undefined (reading 'use_env_variable')
not untarring the bundle
sed: can't read ./dist/mobile/.js: No such file or directory
{"level":"info","message":"[process service types] JOBS_RUNNER","timestamp":"2024-05-28T14:22:59.558Z"}
'"---------------------------"
'"- EXITING RETOOL -"
'"---------------------------"
Error running database migrations: TypeError: Cannot read properties of undefined (reading 'use_env_variable')
not untarring the bundle
sed: can't read ./dist/mobile/
.js: No such file or directory
{"level":"info","message":"[process service types] MAIN_BACKEND, DB_CONNECTOR, DB_SSH_CONNECTOR","timestamp":"2024-05-28T20:19:34.737Z"}
Failing checking database migrations
/retool_backend/bundle/main.js:32
);ev0=!0}}function sD(){let e=O60.default.scope().active()?.context().toTraceId();if(e)return D60.get(e)||0}function NW(){let e=O60.default.scope().active()?.context().toTraceId();if(e){let t=D60.get(e)||0;D60.set(e,t+1||1)}}var O60,rv0,P60,rV1,en,ZE0,ev0,D60,tv0,Nm,Wc=g(()=>{"use strict";O60=h(require("dd-trace")),rv0=h(require("lru-cache")),P60=require("sequelize");F();rV1=b("NODE_ENV")||"development",en=_W()[rV1],ZE0="POSTGRES_CUSTOM_SSL_CERT_PATH & POSTGRES_CUSTOM_SSL_CA_FILE_NAME (and optionally POSTGRES_CUSTOM_SSL_CERT_FILE_NAME & POSTGRES_CUSTOM_SSL_KEY_FILE_NAME) \u2014 see https://docs.retool.com/docs/environment-variables",ev0=!1;D60=new rv0.default({max:100,ttl:10*60*1e3});tv0={beforeFind:e=>{NW()},beforeSave:(e,t)=>{NW()},beforeUpdate:(e,t)=>{NW()},beforeDestroy:(e,t)=>{NW()}};Nm=()=>en.use_env_variable?new P60.Sequelize(String(process.env[en.use_env_variable]),{logging:en.logging,dialectOptions:en.dialectOptions,hooks:tv0}):new P60.Sequelize(en.database,en.username,en.password,{...en,hooks:tv0})});var av0={};l0(av0,{executeMigrations:()=>nv0,exitIfPendingMigrations:()=>aV1,pendingDatabaseMigrations:()=>Rh,runMigrations:()=>sV1});function oV1(){let e=N60.join(__dirname,"../migrations"),t=N60.join(__dirname,"./migrations");return!_60.default.existsSync(e)&&_60.default.existsSync(t)?t:e}function ov0(e){let t=r=>{process.env.NODE_ENV!=="test"&&console.log(r)};return new UW.Umzug({migrations:{glob:${oV1()}/.js,resolve:({name:r,path:o,context:n})=>{let a=require(o);return{name:r,up:async()=>a.up(...n),down:async()=>a.down(...n)}}},context:[e.getQueryInterface(),BW.Sequelize],storage:new UW.SequelizeStorage({sequelize:e}),logger:{info:t,debug:t,warn:t,error:r=>{process.env.NODE_ENV!=="test"&&console.error(r)}}})}async function nv0(){let e=Nm(),t=ov0(e),r=0;try{for(;await Rh(e)!==0&&(b("DISABLE_DATABASE_MIGRATIONS_TIMEOUT")||r<iD);){let n=!1,a;try{console.log("Acquiring lock to run migrations..."),a=await e.transaction(),(await e.query(SELECT pg_try_advisory_xact_lock(${nV1}) AS migration_lock_result,{type:BW.QueryTypes.SELECT,transaction:a}))[0].migration_lock_result?(console.log("Acquired lock"),await Rh(e)===0?console.log("Releasing lock... no migrations to run"):(console.log("Running database migrations..."),await t.up())):(console.log(Could not acquire lock, retrying in ${VS/1e3} second(s)...),n=!0)}finally{a&&await a.commit(),n&&(r+=1,await new Promise(s=>setTimeout(s,VS)))}}let o=await Rh(e);if(o===0){console.log("Database migrations are up to date.");return}if(!b("DISABLE_DATABASE_MIGRATIONS_TIMEOUT")&&r>=iD){console.error(Could not acquire lock after ${iD} attempts at ${VS/1e3} second intervals.),console.error(There ${o>1?"are":"is"} ${o} pending database ${o>1?"migrations":"migration"}. If you are running multiple containers, another container has acquired the lock and is still running migrations... After it completes, please restart this container.);return}}finally{e&&await e.close()}}async function Rh(e){let t;try{return t=e||Nm(),b("RETOOL_HOSTED")||await x60(t),(await ov0(t).pending()).length}catch(r){throw console.error("Failing checking database migrations"),r}finally{!e&&t&&await t.close()}}async function aV1(e){let t=0,r=0;for(;b("DISABLE_DATABASE_MIGRATIONS_TIMEOUT")||t<iD;)if(r=await Rh(e),r===0){console.log("Database migrations are up to date.");return}else console.log(There ${r>1?"are":"is"} ${r} pending database ${r>1?"migrations":"migration"}, checking for up-to-date schema in ${VS/1e3} second(s). If this message persists, ensure that Jobs Runner is up and is running a matching image version.),t+=1,await new Promise(o=>setTimeout(o,VS));!b("DISABLE_DATABASE_MIGRATIONS_TIMEOUT")&&t>=iD&&(console.error(
^
TypeError: Cannot read properties of undefined (reading 'use_env_variable')
at Nm (/retool_backend/bundle/main.js:32:812)
at Rh (/retool_backend/bundle/main.js:32:3010)
at aV1 (/retool_backend/bundle/main.js:32:3281)
at wY2 (/retool_backend/bundle/main.js:4155:3864)
at Object. (/retool_backend/bundle/main.js:4155:4729)
at Module._compile (node:internal/modules/cjs/loader:1256:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
at Module.load (node:internal/modules/cjs/loader:1119:32)
at Module._load (node:internal/modules/cjs/loader:960:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:86:12)
Node.js v18.18.2
not untarring the bundle
sed: can't read ./dist/mobile/
.js: No such file or directory
{"level":"info","message":"[process service types] MAIN_BACKEND, DB_CONNECTOR, DB_SSH_CONNECTOR","timestamp":"2024-05-28T20:21:01.903Z"}
Failing checking database migrations
/retool_backend/bundle/main.js:32
);ev0=!0}}function sD(){let e=O60.default.scope().active()?.context().toTraceId();if(e)return D60.get(e)||0}function NW(){let e=O60.default.scope().active()?.context().toTraceId();if(e){let t=D60.get(e)||0;D60.set(e,t+1||1)}}var O60,rv0,P60,rV1,en,ZE0,ev0,D60,tv0,Nm,Wc=g(()=>{"use strict";O60=h(require("dd-trace")),rv0=h(require("lru-cache")),P60=require("sequelize");F();rV1=b("NODE_ENV")||"development",en=_W()[rV1],ZE0="POSTGRES_CUSTOM_SSL_CERT_PATH & POSTGRES_CUSTOM_SSL_CA_FILE_NAME (and optionally POSTGRES_CUSTOM_SSL_CERT_FILE_NAME & POSTGRES_CUSTOM_SSL_KEY_FILE_NAME) \u2014 see https://docs.retool.com/docs/environment-variables",ev0=!1;D60=new rv0.default({max:100,ttl:10*60*1e3});tv0={beforeFind:e=>{NW()},beforeSave:(e,t)=>{NW()},beforeUpdate:(e,t)=>{NW()},beforeDestroy:(e,t)=>{NW()}};Nm=()=>en.use_env_variable?new P60.Sequelize(String(process.env[en.use_env_variable]),{logging:en.logging,dialectOptions:en.dialectOptions,hooks:tv0}):new P60.Sequelize(en.database,en.username,en.password,{...en,hooks:tv0})});var av0={};l0(av0,{executeMigrations:()=>nv0,exitIfPendingMigrations:()=>aV1,pendingDatabaseMigrations:()=>Rh,runMigrations:()=>sV1});function oV1(){let e=N60.join(__dirname,"../migrations"),t=N60.join(__dirname,"./migrations");return!_60.default.existsSync(e)&&_60.default.existsSync(t)?t:e}function ov0(e){let t=r=>{process.env.NODE_ENV!=="test"&&console.log(r)};return new UW.Umzug({migrations:{glob:${oV1()}/*.js,resolve:({name:r,path:o,context:n})=>{let a=require(o);return{name:r,up:async()=>a.up(...n),down:async()=>a.down(...n)}}},context:[e.getQueryInterface(),BW.Sequelize],storage:new UW.SequelizeStorage({sequelize:e}),logger:{info:t,debug:t,warn:t,error:r=>{process.env.NODE_ENV!=="test"&&console.error(r)}}})}async function nv0(){let e=Nm(),t=ov0(e),r=0;try{for(;await Rh(e)!==0&&(b("DISABLE_DATABASE_MIGRATIONS_TIMEOUT")||r<iD);){let n=!1,a;try{console.log("Acquiring lock to run migrations..."),a=await e.transaction(),(await e.query(SELECT pg_try_advisory_xact_lock(${nV1}) AS migration_lock_result,{type:BW.QueryTypes.SELECT,transaction:a}))[0].migration_lock_result?(console.log("Acquired lock"),await Rh(e)===0?console.log("Releasing lock... no migrations to run"):(console.log("Running database migrations..."),await t.up())):(console.log(Could not acquire lock, retrying in ${VS/1e3} second(s)...),n=!0)}finally{a&&await a.commit(),n&&(r+=1,await new Promise(s=>setTimeout(s,VS)))}}let o=await Rh(e);if(o===0){console.log("Database migrations are up to date.");return}if(!b("DISABLE_DATABASE_MIGRATIONS_TIMEOUT")&&r>=iD){console.error(Could not acquire lock after ${iD} attempts at ${VS/1e3} second intervals.),console.error(There ${o>1?"are":"is"} ${o} pending database ${o>1?"migrations":"migration"}. If you are running multiple containers, another container has acquired the lock and is still running migrations... After it completes, please restart this container.);return}}finally{e&&await e.close()}}async function Rh(e){let t;try{return t=e||Nm(),b("RETOOL_HOSTED")||await x60(t),(await ov0(t).pending()).length}catch(r){throw console.error("Failing checking database migrations"),r}finally{!e&&t&&await t.close()}}async function aV1(e){let t=0,r=0;for(;b("DISABLE_DATABASE_MIGRATIONS_TIMEOUT")||t<iD;)if(r=await Rh(e),r===0){console.log("Database migrations are up to date.");return}else console.log(There ${r>1?"are":"is"} ${r} pending database ${r>1?"migrations":"migration"}, checking for up-to-date schema in ${VS/1e3} second(s). If this message persists, ensure that Jobs Runner is up and is running a matching image version.),t+=1,await new Promise(o=>setTimeout(o,VS));!b("DISABLE_DATABASE_MIGRATIONS_TIMEOUT")&&t>=iD&&(console.error(
TypeError: Cannot read properties of undefined (reading 'use_env_variable')
at Nm (/retool_backend/bundle/main.js:32:812)
at Rh (/retool_backend/bundle/main.js:32:3010)
at aV1 (/retool_backend/bundle/main.js:32:3281)
at wY2 (/retool_backend/bundle/main.js:4155:3864)
at Object. (/retool_backend/bundle/main.js:4155:4729)

Hello @Rodrigo_Carrizo!

Unfortunately there error messages are very vague and there could be a number of factors that could be causing the error and message :sweat_smile:

I would recommend using AI like chat GPT to break down what the error is saying and what you can do to fix these.

From the early lines it looks like the service is looking for a file that it cannot find at file path ./dist/mobile/.js

As well as not being able to read the use_env_variable

Maybe some other users have run into a similar bug and can chime in to help. Also we might be able to live debug at our Retool office hours as well, it is very hard to trouble shoot complex deployment bugs over the forums unfortunately :sweat:

Hello, now I improve the error:

Failing checking database migrations

);mge=!0}}function ED(){let e=jK.default.scope().active()?.context().toTraceId();if(e)return HK.get(e)||0}function VU(){let e=jK.default.scope().active()?.context().toTraceId();if(e){let t=HK.get(e)||0;HK.set(e,t+1||1)}}var jK,gge,VK,Lwt,wc,pge,mge,HK,fge,Qg,zg=f(()=>{"use strict";jK=y(require("dd-trace")),gge=y(require("lru-cache")),VK=require("sequelize");D();Lwt=w("NODE_ENV")||"development",wc=zU()[Lwt],pge="POSTGRES_CUSTOM_SSL_CERT_PATH & POSTGRES_CUSTOM_SSL_CA_FILE_NAME (and optionally POSTGRES_CUSTOM_SSL_CERT_FILE_NAME & POSTGRES_CUSTOM_SSL_KEY_FILE_NAME) \u2014 see https://docs.retool.com/docs/environment-variables",mge=!1;HK=new gge.default({max:100,ttl:10*60*1e3});fge={beforeFind:e=>{VU()},beforeSave:(e,t)=>{VU()},beforeUpdate:(e,t)=>{VU()},beforeDestroy:(e,t)=>{VU()}};Qg=()=>wc.use_env_variable?new VK.Sequelize(String(process.env[wc.use_env_variable]),{logging:wc.logging,dialectOptions:wc.dialectOptions,hooks:fge}):new VK.Sequelize(wc.database,wc.username,wc.password,{...wc,hooks:fge})});var wge={};Y(wge,{executeMigrations:()=>hge,exitIfPendingMigrations:()=>qwt,pendingDatabaseMigrations:()=>tT,runMigrations:()=>Gwt});function Fwt(){let e=JK.join(__dirname,"../migrations"),t=JK.join(__dirname,"./migrations");return!YK.default.existsSync(e)&&YK.default.existsSync(t)?t:e}function yge(e){return new Uwt({migrations:{pattern:/\.(js)$/,path:Fwt(),params:[e.getQueryInterface(),jU.Sequelize]},storage:"sequelize",storageOptions:{sequelize:e},logging:t=>{process.env.NODE_ENV!=="test"&&console.log(t)}})}async function hge(){let e=Qg(),t=yge(e),r=0;try{for(;await tT(e)!==0&&(w("DISABLE_DATABASE_MIGRATIONS_TIMEOUT")||r<ID);){let n=!1,a;try{console.log("Acquiring lock to run migrations..."),a=await e.transaction(),(await e.query(`SELECT pg_try_advisory_xact_lock(${Wwt}) AS migration_lock_result`,{type:jU.QueryTypes.SELECT,transaction:a}))[0].migration_lock_result?(console.log("Acquired lock"),await tT(e)===0?console.log("Releasing lock... no migrations to run"):(console.log("Running database migrations..."),await t.up())):(console.log(`Could not acquire lock, retrying in ${eI/1e3} second(s)...`),n=!0)}finally{a&&await a.commit(),n&&(r+=1,await new Promise(s=>setTimeout(s,eI)))}}let o=await tT(e);if(o===0){console.log("Database migrations are up to date.");return}if(!w("DISABLE_DATABASE_MIGRATIONS_TIMEOUT")&&r>=ID){console.error(`Could not acquire lock after ${ID} attempts at ${eI/1e3} second intervals.`),console.error(`There ${o>1?"are":"is"} ${o} pending database ${o>1?"migrations":"migration"}. If you are running multiple containers, another container has acquired the lock and is still running migrations... After it completes, please restart this container.`);return}}finally{e&&await e.close()}}async function tT(e){let t;try{return t=e||Qg(),w("RETOOL_HOSTED")||await KK(t),(await yge(t).pending()).length}catch(r){throw console.error("Failing checking database migrations"),r}finally{!e&&t&&await t.close()}}async function qwt(e){let t=0,r=0;for(;w("DISABLE_DATABASE_MIGRATIONS_TIMEOUT")||t<ID;)if(r=await tT(e),r===0){console.log("Database migrations are up to date.");return}else console.log(`There ${r>1?"are":"is"} ${r} pending database ${r>1?"migrations":"migration"}, checking for up-to-date schema in ${eI/1e3} second(s)...`),t+=1,await new Promise(o=>setTimeout(o,eI));!w("DISABLE_DATABASE_MIGRATIONS_TIMEOUT")&&t>=ID&&(console.error(

Hello @Rodrigo_Carrizo!

Unfortunately there is not much I can do to help you debug this as the error message is very complex and I am unfamiliar with your self hosted set up :sweat:

It sounds like you were able to make progress from the previous message which is good to see!

I would follow our docs for setting up self hosted based on what configurations you would like to use. Let me know if there are specific docs you are looking to find and I can help direct you to them and their startup instructions for self-hosting your AWS using Docker Compose with Terraform.

we are using this image:

ecs_retool_image = "tryretool/backend:3.28.7"
ecs_code_executor_image = "tryretool/code-executor-service:3.28.7"

What would be the correct image?

Hello @Rodrigo_Carrizo!

I was able to run the images with

tryretool/backend:3.52.7-stable

and

tryretool/code-executor-service:3.52.7-stable