From ba0a184a3892a72229704d9fe843f182b08acff7 Mon Sep 17 00:00:00 2001 From: Jan-Henrik Damaschke Date: Fri, 17 Feb 2023 01:26:09 +0100 Subject: [PATCH 1/4] docs(docs): Added workers page for edge limitations --- docs/content/2.deploy/2.workers.md | 56 ++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 docs/content/2.deploy/2.workers.md diff --git a/docs/content/2.deploy/2.workers.md b/docs/content/2.deploy/2.workers.md new file mode 100644 index 0000000000..70671746d5 --- /dev/null +++ b/docs/content/2.deploy/2.workers.md @@ -0,0 +1,56 @@ +--- +title: Workers +description: Nitro provides out of the box support for deploying to Edge Workers. +--- + +## Deploy to Workers + +Nitro provides out of the box support for deploying to different Edge Worker offerings as well as service workers. + +- [cloudflare](/deploy/providers/cloudflare#cloudflare-workers) +- [vercel](/deploy/providers/vercel#vercel-edge-functions) +- service-workers ([switch to this preset](/deploy/#changing-the-deployment-preset)) + +::alert{type="warning"} +**Limitations** +:br +Deploying to edge workers has some limitations. See [limitations](/deploy/workers/#limitations) for more details. +:: + +### Limitations + +- No support for raw TCP/IP traffic +- Execution time is limited compared to classic serverless offerings (normally 15-30 seconds) +- Limited access to storage + +> You can use the [unstorage](/guide/introduction/storage) driver `cloudflare-kv-http` or `cloudflare-kv-bindings` for Cloudflare workers + +- Size is very limited (normally a few MBs) +- Limited or no access to Node.js APIs + - [Cloudflare Workers APIs](https://developers.cloudflare.com/workers/runtime-apis) + - [Vercel Edge Functions APIs](https://vercel.com/docs/concepts/functions/edge-functions/edge-functions-api) + +### Incompatible libraries + +::alert{type="info"} +**Help us** +:br +If you come across a library that you assume to be incompatible with edge workers, please open an issue on the [nitro repo](https://github.com/unjs/nitro/issues/new/choose) and help us keeping this list up to date. +:: + +The following libraries are known to be incompatible with edge workers because of one of the above mentioned limitations: + +- `mongodb` + +> There are possible fixes for MongoDB, like using Realm and the [Realm SDK](https://www.mongodb.com/docs/realm/sdk/node/) or +> using http interfaces (only available when self hosting MongoDB), but these are untested. + +- `mysql` + +> You can find an example with a modified MySQL driver [here](https://github.com/cloudflare/worker-template-mysql) + +- `rhea` +- `gremlin` +- `ioredis` +- `cassandra-driver` +- `kafkajs` From fc4df3efa16f4de53464a697a8761b2b8877f14d Mon Sep 17 00:00:00 2001 From: Jan-Henrik Damaschke Date: Mon, 20 Feb 2023 20:57:32 +0100 Subject: [PATCH 2/4] docs(workers): Added realm example Added realm example by @manniL --- docs/content/2.deploy/2.workers.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/content/2.deploy/2.workers.md b/docs/content/2.deploy/2.workers.md index 70671746d5..ceb9cd6662 100644 --- a/docs/content/2.deploy/2.workers.md +++ b/docs/content/2.deploy/2.workers.md @@ -43,7 +43,7 @@ The following libraries are known to be incompatible with edge workers because o - `mongodb` > There are possible fixes for MongoDB, like using Realm and the [Realm SDK](https://www.mongodb.com/docs/realm/sdk/node/) or -> using http interfaces (only available when self hosting MongoDB), but these are untested. +> using http interfaces (only available when self hosting MongoDB), but these are untested. You can find an example for using realm [here](https://github.com/albionstatus/albionstatus-backend/) - `mysql` From 4010c6c635421d9a1ebe33664643379c644c7b22 Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Tue, 21 Feb 2023 13:50:00 +0100 Subject: [PATCH 3/4] small updates --- docs/content/2.deploy/2.workers.md | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/docs/content/2.deploy/2.workers.md b/docs/content/2.deploy/2.workers.md index ceb9cd6662..ab8a8052cb 100644 --- a/docs/content/2.deploy/2.workers.md +++ b/docs/content/2.deploy/2.workers.md @@ -5,11 +5,13 @@ description: Nitro provides out of the box support for deploying to Edge Workers ## Deploy to Workers -Nitro provides out of the box support for deploying to different Edge Worker offerings as well as service workers. +Nitro provides out of the box support for deploying any Nitro app to different Edge Worker offerings as well as Service Workers. -- [cloudflare](/deploy/providers/cloudflare#cloudflare-workers) -- [vercel](/deploy/providers/vercel#vercel-edge-functions) -- service-workers ([switch to this preset](/deploy/#changing-the-deployment-preset)) +- [Cloudflare](/deploy/providers/cloudflare) +- [Vercel](/deploy/providers/vercel#vercel-edge-functions) +- [Netlify](/deploy/providers/netlify#netlify-edge-functions) +- [Lagon] https://nitro.unjs.io/deploy/providers/lagon +- [Browser Service Workers](https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API) (via experimental preset `service-worker`) ::alert{type="warning"} **Limitations** @@ -21,14 +23,9 @@ Deploying to edge workers has some limitations. See [limitations](/deploy/worker - No support for raw TCP/IP traffic - Execution time is limited compared to classic serverless offerings (normally 15-30 seconds) -- Limited access to storage - -> You can use the [unstorage](/guide/introduction/storage) driver `cloudflare-kv-http` or `cloudflare-kv-bindings` for Cloudflare workers - -- Size is very limited (normally a few MBs) -- Limited or no access to Node.js APIs - - [Cloudflare Workers APIs](https://developers.cloudflare.com/workers/runtime-apis) - - [Vercel Edge Functions APIs](https://vercel.com/docs/concepts/functions/edge-functions/edge-functions-api) +- No access to the filesystem (use the [nitro storage](/guide/introduction/storage) layer) +- Budnle size is very limited (normally a few MBs) +- Limited access Node.js APIs (nitro provides compatibility layer via [unjs/unenv](https://github.com/unjs/unenv)) ### Incompatible libraries From 0c2aceae0a00c5d2d0786d0b9a8b42ba88d7629c Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Tue, 21 Feb 2023 13:50:29 +0100 Subject: [PATCH 4/4] update lagon --- docs/content/2.deploy/2.workers.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/content/2.deploy/2.workers.md b/docs/content/2.deploy/2.workers.md index ab8a8052cb..91421ea5fa 100644 --- a/docs/content/2.deploy/2.workers.md +++ b/docs/content/2.deploy/2.workers.md @@ -10,7 +10,7 @@ Nitro provides out of the box support for deploying any Nitro app to different E - [Cloudflare](/deploy/providers/cloudflare) - [Vercel](/deploy/providers/vercel#vercel-edge-functions) - [Netlify](/deploy/providers/netlify#netlify-edge-functions) -- [Lagon] https://nitro.unjs.io/deploy/providers/lagon +- [Lagon](/deploy/providers/lagon) - [Browser Service Workers](https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API) (via experimental preset `service-worker`) ::alert{type="warning"}