Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(deploy): add workers page for edge limitations #953

Merged
merged 4 commits into from
Feb 21, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions docs/content/2.deploy/2.workers.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
---
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 any Nitro app to different Edge Worker offerings as well as Service Workers.

- [Cloudflare](/deploy/providers/cloudflare)
- [Vercel](/deploy/providers/vercel#vercel-edge-functions)
- [Netlify](/deploy/providers/netlify#netlify-edge-functions)
- [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"}
**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)
- 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

::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. You can find an example for using realm [here](https://github.com/albionstatus/albionstatus-backend/)

- `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`