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

*.d.ts file not cached #18583

Closed
marvinhagemeister opened this issue Apr 3, 2023 · 10 comments · Fixed by #19392
Closed

*.d.ts file not cached #18583

marvinhagemeister opened this issue Apr 3, 2023 · 10 comments · Fixed by #19392
Assignees
Labels
bug Something isn't working correctly

Comments

@marvinhagemeister
Copy link
Contributor

marvinhagemeister commented Apr 3, 2023

Whenever I run the deno task start command in the fresh repo it seems to re-download two typing files.

Screenshot 2023-04-04 at 01 31 10

Steps to reproduce:

  1. git clone [email protected]:denoland/fresh.git
  2. cd fresh
  3. deno task www
  4. Press cmd+c or ctrl+c
  5. Run the same task again
@bartlomieju
Copy link
Member

@marvinhagemeister I have trouble reproduction the problem - after running 1. and 2. I get an error about ask not existing:

fresh on  main via 🦕 v1.32.3 via  v19.6.0 on ☁️  [email protected]
❯ deno task start
Task not found: start
Available tasks:
- test
    deno test -A && deno check --config=www/deno.json www/main.ts www/dev.ts && deno check init.ts
- fixture
    deno run -A --watch=static/,routes/ tests/fixture/dev.ts
- www
    deno run -A --watch=www/static/,www/routes/,docs/ www/dev.ts
- screenshot
    deno run -A www/utils/screenshot.ts

@bartlomieju
Copy link
Member

I assume you meant deno task www. With that task I can see that these deps are downloaded on each run.

@dsherret dsherret added the bug Something isn't working correctly label Apr 4, 2023
@ayame113
Copy link
Contributor

ayame113 commented Apr 4, 2023

I think these issues are related:

@iuioiua
Copy link
Contributor

iuioiua commented Apr 4, 2023

Likely related:

@marvinhagemeister
Copy link
Contributor Author

marvinhagemeister commented Apr 4, 2023

@bartlomieju Whoops, my bad, you're correct. Meant deno task www instead of deno task start. Corrected the original post.

@marvinhagemeister
Copy link
Contributor Author

marvinhagemeister commented Apr 4, 2023

Some more hints:

We try to cache this URL https://esm.sh/v113/@types/katex@~0.16/dist/katex.mjs~.d.ts, but when reading from the cache we look up this URL https://esm.sh/v113/@types/[email protected]/dist/katex.mjs~.d.ts. There is a very minor difference around the version string: katex@~0.16 vs [email protected]. This mismatch means that the cached file is never found on disk. Basically we're looking up the cache with a different cache key than under which we stored the file.

@marvinhagemeister
Copy link
Contributor Author

marvinhagemeister commented Apr 4, 2023

Some more info:

When https://esm.sh/[email protected]/dist/katex.mjs is fetched, esm.sh returns a x-typescript-types header which points to https://esm.sh/v113/@types/katex@~0.16/dist/katex.mjs~.d.ts. Reason is likely that there is no exact version match for the types packages and it defaults to the latest or tries to resolve a range.

Specifying a range seems to be a sensible thing to define, but problem is that the path name dist/katex.mjs~.d.ts doesn't exist and returns a 404. This means that nothing is put into cache on disk, which in turn leads to deno always re-checking if such a file exists, the cache lookup fails and it reaches back out to the network again.

The value it should have resolved to is https://esm.sh/v113/@types/[email protected]/index.d.ts. Wondering if that is a bug in esm.sh.

@marvinhagemeister
Copy link
Contributor Author

marvinhagemeister commented Apr 4, 2023

Looks like the x-typescript-types header is correct when I don't access the resolved main entry point myself, but let esm.sh do it. If I go to https://esm.sh/[email protected] the header is correct, but when I access a file directly it's wrong.

URL x-typescript-types
https://esm.sh/[email protected]/dist/katex.mjs https://esm.sh/v113/@types/katex@~0.16/dist/katex.mjs~.d.ts
https://esm.sh/[email protected] https://esm.sh/v113/@types/katex@~0.16/index.d.ts

@marvinhagemeister
Copy link
Contributor Author

Filed an issue over at the esm.sh repo. I think the bug lies there, but the fact that we have no concept of a package in deno doesn't make this easy for them.

@marvinhagemeister
Copy link
Contributor Author

Alright, PR'ed a fix for this to esm.sh esm-dev/esm.sh#579

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working correctly
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants