-
Notifications
You must be signed in to change notification settings - Fork 774
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
Untangle wrangler
types 🙈
#2377
Conversation
🦋 Changeset detectedLatest commit: 56a15ed The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
@@ -541,7 +541,7 @@ export const Handler = async ({ | |||
|
|||
CLEANUP_CALLBACKS.push(stop); | |||
|
|||
waitUntilExit().then(() => { | |||
void waitUntilExit().then(() => { |
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.
Perhaps this should just use a .finally
instead?
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.
Probably, but we aren't really doing anything with the Promise
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.
Hmmm, if this throw
s, we probably don't want to exit with code 0
? Unhandled rejections will trigger the process.on("exit")
listener below too.
A wrangler prerelease is available for testing. You can install this latest build in your project with: npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/runs/3685450343/npm-package-wrangler-2377 You can reference the automatically updated head of this PR with: npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/prs/2377/npm-package-wrangler-2377 Or you can use npx https://prerelease-registry.devprod.cloudflare.dev/runs/3685450343/npm-package-wrangler-2377 dev path/to/script.js Additional artifacts:npm install https://prerelease-registry.devprod.cloudflare.dev/runs/3685450343/npm-package-cloudflare-pages-shared-2377 |
Codecov Report
@@ Coverage Diff @@
## main #2377 +/- ##
==========================================
+ Coverage 70.71% 71.46% +0.75%
==========================================
Files 153 153
Lines 9751 9644 -107
Branches 2550 2515 -35
==========================================
- Hits 6895 6892 -3
+ Misses 2856 2752 -104
|
46cfa63
to
7942c1d
Compare
I was joking when I said to try and change more files... 😂 |
const response = await env.ASSETS.fetch(request.url, request); | ||
const response = await env.ASSETS.fetch( | ||
request.url, | ||
request as RequestInit<RequestInitCfProperties> |
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.
Why is this cast needed?
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.
This is probably a bug in @cloudflare/workers-types
tbh. The cf
types from the fetch
handler request
parameter and global fetch
were incompatible.
7942c1d
to
7a99683
Compare
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.
Once the cf
casting issue is fixed, this looks good to go!
@@ -332,7 +332,7 @@ describe("r2", () => { | |||
"host": "api.cloudflare.com", | |||
} | |||
`); | |||
response.once( | |||
return response.once( |
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.
ugh... ty for catching these, little disappointed the tests were passing without them returning the response properly, and I overlooked them.
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.
Hmmm, would you be able to have a look and see what's going on here?
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.
After I finishing converting the other tests, for sure.
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.
Likely something like this in these tests too #2377 (comment)
@@ -119,7 +119,7 @@ function* executeRequest(request: Request, relativePathname: string) { | |||
} | |||
} | |||
|
|||
export default function (pluginArgs) { | |||
export default function (pluginArgs: unknown) { |
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.
I am guessing this was undefined
before
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.
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.
Oh no O_O
7a99683
to
56a15ed
Compare
@penalosa In the interest of avoiding this PR going stale, and bearing in mind the time it will take to get a |
Yeah, I'm good with that—can you make an issue to fix? (I know the ts-expect-error will catch it, but just for tracking) |
Updated #2390 👍 |
Whilst fixing another bug, I noticed
fetch
was in the global typing environment forwrangler
. This shouldn't be the case, as our minimum supported Node version is 16.13.0, which doesn't include globalfetch
. Digging deeper, I noticed lots of files were being typed with a mix of@cloudflare/workers-types
,node
andjest
types. This meant we could happily write a Jestdescribe
in Wrangler CLI code, and TypeScript wouldn't complain. Not good... 😅This PR splits
wrangler
's directories into separate TypeScript projects, each with their own configuration, and makes sure we aren't importing files that pollute global types. This ensures files get type checked under the correct environment.A new
tsc-all.js
script has been added that automatically runstsc
on each project.tsconfig-santiy.ts
files have also been added with@ts-expect-error
comments to make sure this doesn't happen again.I've also fixed the type checking of
fixtures
, and incorporated this into our rootcheck
script.