-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
feat(build): fetch Railpack versions dynamically from GitHub releases #4070
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
base: canary
Are you sure you want to change the base?
Changes from all commits
d048fec
c56adea
eb5601c
b7ff490
fc2a072
9b8d167
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -1103,6 +1103,21 @@ export const applicationRouter = createTRPCRouter({ | |||||||||
| }; | ||||||||||
| }), | ||||||||||
|
|
||||||||||
| getRailpackVersions: protectedProcedure.query(async () => { | ||||||||||
| const res = await fetch( | ||||||||||
| "https://api.github.com/repos/railwayapp/railpack/releases", | ||||||||||
| { headers: { Accept: "application/vnd.github+json" } }, | ||||||||||
|
Comment on lines
+1107
to
+1109
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The
Suggested change
|
||||||||||
| ); | ||||||||||
| if (!res.ok) { | ||||||||||
| throw new TRPCError({ | ||||||||||
| code: "INTERNAL_SERVER_ERROR", | ||||||||||
| message: "Failed to fetch Railpack versions from GitHub", | ||||||||||
| }); | ||||||||||
| } | ||||||||||
| const releases = (await res.json()) as Array<{ tag_name: string }>; | ||||||||||
| return releases.map((r) => r.tag_name.replace(/^v/, "")); | ||||||||||
| }), | ||||||||||
|
Comment on lines
+1106
to
+1119
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The endpoint makes a fresh GitHub API call on every invocation. GitHub's unauthenticated rate limit is 60 requests/hour per IP address. Because the Dokploy server makes these calls (all users share one IP), a busy instance with multiple users opening the Railpack build tab can exhaust this limit very quickly, causing every subsequent call to fail with a 403/429. The client-side A simple fix is to add a server-side in-memory cache (e.g. a module-level variable with a timestamp) or use a const res = await fetch(
"https://api.github.com/repos/railwayapp/railpack/releases",
{
headers: {
Accept: "application/vnd.github+json",
...(process.env.GITHUB_TOKEN
? { Authorization: `Bearer ${process.env.GITHUB_TOKEN}` }
: {}),
},
},
); |
||||||||||
|
|
||||||||||
| readLogs: protectedProcedure | ||||||||||
| .input( | ||||||||||
| apiFindOneApplication.extend({ | ||||||||||
|
|
||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the user switches to Railpack and submits before
getRailpackVersionsresolves (or if the GitHub API request fails entirely),data.railpackVersionisnull(the schema default) andrailpackVersions?.[0]isundefined. The expression evaluates to"".replace(/^v/, "")→"", which silently saves an empty string as the build version, causing the next build to fail without a clear error.The Save button should be disabled while versions are loading, or a validation should reject an empty version:
Pairing this with disabling the Save button while
isLoadingRailpackVersionsis true would fully close the gap.