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

Ratelimit: unclear error #2460

Open
3 tasks done
AmitMY opened this issue Oct 16, 2024 · 15 comments
Open
3 tasks done

Ratelimit: unclear error #2460

AmitMY opened this issue Oct 16, 2024 · 15 comments

Comments

@AmitMY
Copy link

AmitMY commented Oct 16, 2024

Preliminary Checks

Reproduction / Replay Link (Optional)

No response

Issue Summary

I'm trying to start using ratelimit, but getting

Ratelimit failed: [undefined - undefined]: undefined

In the console I see:

2024-10-16T08:44:41.547Z 93.39MB: attempt %d of %d to reach %s failed, retrying in %d ms: %s | %s 6 6 URL {
href: 'https://api.unkey.dev/v1/ratelimits.limit',
origin: 'https://api.unkey.dev',
protocol: 'https:',
username: '',
password: '',
host: 'api.unkey.dev',
hostname: 'api.unkey.dev',
port: '',
pathname: '/v1/ratelimits.limit',
search: '',
searchParams: URLSearchParams {},
hash: ''
} 1484 status=404 req_3js77ZAQPKVhW8fdqNCsWMM3PfDp

Steps to Reproduce

Following the tutorial

    const rateLimit = new Ratelimit({
      rootKey,
      namespace,
      limit,
      duration,
    });

    const ratelimitResponse = await rateLimit.limit('unknown');

Expected behavior

The error should be better.

Other information

No response

Screenshots

No response

Version info

- OS: macOS 15.0.1 (24A348)
- Node: v22.0.0
- npm: 10.5.1

Unkey version:     "@unkey/ratelimit": "0.4.5",
@AmitMY AmitMY added Bug Something isn't working Needs Approval Needs approval from Unkey labels Oct 16, 2024
Copy link

linear bot commented Oct 16, 2024

@chronark
Copy link
Collaborator

Ihey @AmitMY, I just tried to reproduce it but it worked
could you create a minimal reproducable example that I could check out?

@AmitMY
Copy link
Author

AmitMY commented Oct 16, 2024

I found why this happens - if the namespace is wrong (I misspelled) then it returns a 404

@chronark
Copy link
Collaborator

@AmitMY ah I found out why

yes, it's related to the namespace
your root key doesn't have permission to create a new namespace.

We're not passing the error through to the client though, which makes this hard to debug

{
  "error": {
    "code": "NOT_FOUND",
    "docs":" https://unkey.dev/docs/api-reference/errors/code/NOT_FOUND",
    "message":"namespace namespacetahtdoesnotexist not found",
    "requestId":"req_3jv6ECNqFJwAad9P7NsTnktuj1iy"
  }
} 

@AmitMY
Copy link
Author

AmitMY commented Oct 16, 2024

but you are returning a 404. I think that should be the indication for wrong namespace

@chronark
Copy link
Collaborator

yeah, the status is fine, but we should tell you exactly what's happening, not just show a 404

@ahmed2tech28
Copy link

/assign

Copy link

oss-gg bot commented Oct 16, 2024

Assigned to @ahmed2tech28! Please open a draft PR linking this issue within 48h ⚠️ If we can't detect a PR from you linking this issue in 48h, you'll be unassigned automatically 🕹️ Excited to have you ship this 🚀

@vivekk-dev
Copy link

/assign

Copy link

oss-gg bot commented Oct 17, 2024

This issue is already assigned to another person. Please find more issues here.

Copy link

oss-gg bot commented Oct 18, 2024

@ahmed2tech28, Just a little reminder: Please open a draft PR linking this issue within 12 hours. If we can't detect a PR in 12h, you will be unassigned automatically.

1 similar comment
Copy link

oss-gg bot commented Oct 20, 2024

@ahmed2tech28, Just a little reminder: Please open a draft PR linking this issue within 12 hours. If we can't detect a PR in 12h, you will be unassigned automatically.

Copy link

oss-gg bot commented Oct 22, 2024

@ahmed2tech28, Just a little reminder: Please open a draft PR linking this issue within 12 hours. If we can't detect a PR in 12h, you will be unassigned automatically.

@Kartikey1306
Copy link

/assign

Copy link

oss-gg bot commented Oct 23, 2024

This issue is already assigned to another person. Please find more issues here.

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

No branches or pull requests

6 participants