Back

Node(Express) backend deployment issues

  • 1
  • Functions
Slayer
17 Sep, 2024, 20:52

Hey folks,

I’m hitting a wall with deploying my Node.js 18 app (using Express and TypeScript) to Appwrite. This is my first time with Appwrite and backend stuff, so I’m a bit stuck.

Here’s the Setup Stack: Node.js 18, Express, TypeScript Build Command:

yarn install --production=false && yarn build && node fix-extensions.js && yarn install --production --frozen-lockfile && node dist/server.js

First, install everything (yarn install --production=false).

Then build the app (yarn build).

Run a script to fix import extensions (node fix-extensions.js).

Reinstall just the production dependencies (yarn install --production --frozen-lockfile).

Finally, start the app (node dist/server.js).

so I am putting the entry point as dist/server.js as well in this case

The Problem When I deploy, I get these errors:

Initial Error:

{"message":"Runtime not ready. Container not found.","code":500,"version":"0.6.10"} This happens almost right away.

Timeout Error:(second error)

{"message":"Synchronous function execution timed out. Use asynchronous execution instead, or ensure the execution duration doesn't exceed 30 seconds."} After the first error, it seems like the deployment just times out(after 30 minutes of building ?) .

Everything works perfectly on my local setup, so it seems like it’s an Appwrite-specific issue? or i am not sure ? anyone has any ideas ?

TL;DR
Developers are experiencing deployment issues with Node.js (Express) backend on Appwrite. They tried a bare-bones project with just Node + TypeScript, which worked locally but not on Appwrite. They suspect it might be a TypeScript issue rather than Express. The error suggests a timeout due to synchronous function execution. Suggestions include trying a demo/bare-bones function and considering if Express works on functions with Appwrite being Cloud or Self-Hosted. Solution: Consider using asynchronous execution or ensuring the execution duration doesn't exceed 30 seconds.
darShan
18 Sep, 2024, 05:09

if you run a demo/bare-bones function, does it work? Also, express might just not work on functions. Also, Cloud or Self Hosted?

Slayer
18 Sep, 2024, 17:37

thanks for helping ou, and yes this is gonna be Cloud hosted and yeah i just tried a bare-bones project with just node + typescript to see if it works, and it worked locally but in appwrite the same issue presented again.

this is my sever.ts

import { createServer } from 'http';

const server = createServer((req, res) => { res.statusCode = 200; res.setHeader('Content-Type', 'text/plain'); res.end('Hello from a barebones Node.js + TypeScript project!'); });

const PORT = process.env.PORT || 3000;

server.listen(PORT, () => { console.log(Server running at http://localhost:${PORT}/); });

and this is my package.json

{ "name": "barebonesNode", "version": "1.0.0", "main": "dist/server.js", "license": "MIT", "scripts": { "build": "tsc", "start": "node src/server.js" }, "dependencies": { "@types/node": "^18.0.0", "typescript": "^5.6.2" } }

so, i dont think the issue is with express, since i am not using it in this bare-bones project - maybe it's typescript ?

the error was this as before on Appwrite

Synchronous function execution timed out. Use asynchronous execution instead, or ensure the execution duration doesn't exceed 30 seconds.

@darShan

darShan
18 Sep, 2024, 17:44

i dnt think express would work on appwrite.

darShan
18 Sep, 2024, 17:44
Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more