You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
| MemoryStore | (default) Simple in-memory option. Does not share state when the app has multiple processes or servers. |
94
-
|[@hono-rate-limiter/redis](https://www.npm.im/@hono-rate-limiter/redis)| A [Redis](https://redis.io/)-backed store, used with [`@vercel/kv`](https://www.npmjs.com/package/@vercel/kv) and [`@upstash/redis`](https://www.npmjs.com/package/@upstash/redis) . [](https://www.npmjs.com/package/@hono-rate-limiter/redis)|
| MemoryStore | (default) Simple in-memory option. Does not share state when the app has multiple processes or servers. |
94
+
|[@hono-rate-limiter/redis](https://www.npm.im/@hono-rate-limiter/redis)| A [Redis](https://redis.io/)-backed store, used with [`@vercel/kv`](https://www.npmjs.com/package/@vercel/kv) and [`@upstash/redis`](https://www.npmjs.com/package/@upstash/redis) . [](https://www.npmjs.com/package/@hono-rate-limiter/redis)|
95
95
|[@hono-rate-limiter/cloudflare](https://www.npm.im/@hono-rate-limiter/cloudflare)| A [Cloudflare](https://www.cloudflare.com/)-backed store, used with [Durable Object](https://developers.cloudflare.com/durable-objects/), [WorkersKV](https://developers.cloudflare.com/kv/) and [Workers Rate Limiting](https://developers.cloudflare.com/workers/runtime-apis/bindings/rate-limit/) API. [](https://www.npmjs.com/package/@hono-rate-limiter/cloudflare)|
96
-
|[rate-limit-redis](https://npm.im/rate-limit-redis)| A [Redis](https://redis.io/)-backed store, more suitable for large or demanding deployments. |
97
-
|[rate-limit-postgresql](https://www.npm.im/@acpr/rate-limit-postgresql)| A [PostgreSQL](https://www.postgresql.org/)-backed store. |
98
-
|[rate-limit-memcached](https://npmjs.org/package/rate-limit-memcached)| A [Memcached](https://memcached.org/)-backed store. |
99
-
|[cluster-memory-store](https://npm.im/@express-rate-limit/cluster-memory-store)| A memory-store wrapper that shares state across all processes on a single server via the [node:cluster](https://nodejs.org/api/cluster.html) module. Does not share state across multiple servers. |
100
-
|[precise-memory-rate-limit](https://www.npm.im/precise-memory-rate-limit)| A memory store similar to the built-in one, except that it stores a distinct timestamp for each key. |
101
-
|[typeorm-rate-limit-store](https://www.npmjs.com/package/typeorm-rate-limit-store)| Supports a variety of databases via [TypeORM](https://typeorm.io/): MySQL, MariaDB, CockroachDB, SQLite, Microsoft SQL Server, Oracle, SAP Hana, and more. |
102
-
|[@rlimit/storage](https://www.npmjs.com/package/@rlimit/storage)| A distributed rlimit store, ideal for multi-regional deployments. |
96
+
|[rate-limit-redis](https://npm.im/rate-limit-redis)| A [Redis](https://redis.io/)-backed store, more suitable for large or demanding deployments. |
97
+
|[rate-limit-postgresql](https://www.npm.im/@acpr/rate-limit-postgresql)| A [PostgreSQL](https://www.postgresql.org/)-backed store. |
98
+
|[rate-limit-memcached](https://npmjs.org/package/rate-limit-memcached)| A [Memcached](https://memcached.org/)-backed store. |
99
+
|[cluster-memory-store](https://npm.im/@express-rate-limit/cluster-memory-store)| A memory-store wrapper that shares state across all processes on a single server via the [node:cluster](https://nodejs.org/api/cluster.html) module. Does not share state across multiple servers. |
100
+
|[precise-memory-rate-limit](https://www.npm.im/precise-memory-rate-limit)| A memory store similar to the built-in one, except that it stores a distinct timestamp for each key. |
101
+
|[typeorm-rate-limit-store](https://www.npmjs.com/package/typeorm-rate-limit-store)| Supports a variety of databases via [TypeORM](https://typeorm.io/): MySQL, MariaDB, CockroachDB, SQLite, Microsoft SQL Server, Oracle, SAP Hana, and more. |
102
+
|[@rlimit/storage](https://www.npmjs.com/package/@rlimit/storage)| A distributed rlimit store, ideal for multi-regional deployments. |
103
103
104
104
Take a look at this [guide](https://express-rate-limit.mintlify.app/guides/creating-a-store) if you wish to create your own store.
105
105
@@ -121,6 +121,20 @@ If the suggestions here don't work, please try posting questions on [GitHub Disc
121
121
122
122
When working with packages that are not officially supported by `hono-rate-limiter`, you might encounter type-related issues. These can be easily resolved by referring to the discussions in [#22](https://github.com/rhinobase/hono-rate-limiter/issues/22), [#10](https://github.com/rhinobase/hono-rate-limiter/issues/10)
123
123
124
+
### Using `hono-rate-limiter` with Cloudflare Workers or Pages
125
+
126
+
If you're trying to use `hono-rate-limiter` in a Cloudflare environment (such as Workers or Pages), you may encounter the following error:
127
+
128
+
```
129
+
Uncaught Error: Disallowed operation called within global scope. Asynchronous I/O (ex: fetch() or connect()), setting a timeout, and generating random values are not allowed within global scope. To fix this error, perform this operation within a handler. https://developers.cloudflare.com/workers/runtime-apis/handlers/
130
+
```
131
+
132
+
This happens because the default memory store used by `hono-rate-limiter` cannot run in the Cloudflare environment due to its restrictions on global asynchronous operations.
133
+
134
+
#### Solution
135
+
136
+
To resolve this issue, you need to use a compatible store for Cloudflare. You can use the [`@hono-rate-limiter/cloudflare`](https://www.npmjs.com/package/@hono-rate-limiter/cloudflare) package, which is specifically designed to work with Cloudflare's infrastructure.
0 commit comments