Forge deploy command failed when using webtrigger fun with few npm modules

Hello All,

When I am trying to use pg npm module in my webtrigger function, I am getting the below errors. Not sure what could be the blocker from Forge runtime and how can we overcome on this.

Intention of the poc, is to use pg module to connect the postgres database. But before that installed pg and required npm modules. Once done I did forge deploy command which was failed and leads this error.

Can any one please share on this

Bundling failed: Module build failed: UnhandledSchemeError: Reading from “cloudflare:sockets” is not handled by plugins (Unhandled scheme).
Webpack supports “data:” and “file:” URIs by default.
You may need an additional plugin to handle “cloudflare:” URIs.

Hey Guys,

Any one please share any suggestions or help on this post.

Hi DharmaTeja !

The issue is that Forge runs in a sandboxed environment, which means:

  • All external (egress) traffic is blocked by default

  • Only HTTPS requests to domains listed in manifest.yml are allowed

  • Socket-based connections (like using pg to connect to PostgreSQL) won’t work inside Forge

What can you do instead?

1. Use Forge Remote

If you really need to use pg and connect directly to a PostgreSQL database, the best option is to use Forge Remote.

It lets you move your database logic to an external backend (like AWS Lambda or any server), where you can use any npm modules you need.

2. Use Forge SQL

If you prefer to stay fully inside the Forge ecosystem, check out Forge SQL.

It’s a built-in, Mysql-like storage solution with full support for SQL queries. It works out of the box with the @forge/sql package — or forge-sql-orm if you prefer something closer to an ORM-style approach.

No need for sockets or external databases.

Hi @vzakharchenko ,

Thanks for sharing the information about Forge sandbox environment. We are looking both the options @vzakharchenko .

Thank you.