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

Doesn't quite function when using Bun as a runtime #5

Open
W2Wizard opened this issue Feb 23, 2024 · 1 comment
Open

Doesn't quite function when using Bun as a runtime #5

W2Wizard opened this issue Feb 23, 2024 · 1 comment

Comments

@W2Wizard
Copy link

W2Wizard commented Feb 23, 2024

I'm not 100% sure if it's necessarily the fault of this lib itself but I haven't been too successful in terms of boiling it down as to what exactly is the problem.

Basically if you use the bun runtime using: https://github.com/gornostay25/svelte-adapter-bun suddenly when submitting any form requests the response is stuck pending endlessly.

To reproduce simply swap out the adapter with the one I listed above and run with:
bun --bun run dev, click on the submit button and watch it load forever.

I used this repo to conduct the test and I was using the latest (0.5.2) adapter for bun.


Somewhere within this function the problems start.

async check(
event: RequestEvent
): Promise<{ limited: boolean; retryAfter: number }> {
const result = await this._isLimited(event);

I even tried commenting out the 2 funtions that reference the event, no success.
The funny part is, it actually works! As in rate-limiting is being applied if exceeded but the response is somehow lost.

@ciscoheat
Copy link
Owner

Tested with the latest version of everything (on Windows), and this simple page works fine at least:

import type { PageServerLoad } from './$types';
import { error } from '@sveltejs/kit';
import { RateLimiter } from 'sveltekit-rate-limiter/server';

const limiter = new RateLimiter({
	IP: [3, '10s']
});

export const load = (async (event) => {
	if (await limiter.isLimited(event)) throw error(429);
	return {};
}) satisfies PageServerLoad;

If you have a more advanced case that doesn't work, post a link to its repo and I'll take a look.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants