esm-dev / esm.sh

A fast, smart, & global CDN for modern(es2015+) web development.
https://esm.sh
MIT License
3.08k stars 147 forks source link

Failed to import - firebase@9.23.0/app #676

Closed nojaf closed 1 year ago

nojaf commented 1 year ago

Failing module

import { initializeApp} from ":https://esm.sh/firebase@9.23.0/app"

Error message

After onload I got this:

Uncaught SyntaxError: Invalid or unexpected token (at app:1:2))

image

Additional info

This was working yesterday for me.

smcardle commented 1 year ago

This looks to be a serious issue with esm.sh in general. Most of the libraries I am using are scrambled in the same way including back to version v89 (the oldest I use) through the latest. I thought the whole point of esm.sh was that any updates DO NOT affect older versions already in the CDN

example; https://esm.sh/v89/lodash@4.17.21

output

!�� W����s�O� 6�D,����e���9^�KĐ�=_+ЍY�V��e�+2Qȯi\6�p|4Q�m��bk��e������(��Y�+��F~�

Additional note:

We reference the url's in the browser importmap imports section. This has been working for a very long time and it now not working at all

thatcher-gaming commented 1 year ago

yeah, i'm getting this too when fetching preact. seems to happen basically at random

ije commented 1 year ago

sorry, a mistake i made broken the cache key of CF R2, i am going to revert the commit

ije commented 1 year ago

the server is back to normal, @smcardle @nojaf @thatcher-gaming can you please try again

thatcher-gaming commented 1 year ago

image all good now :)

mkeftz commented 1 year ago

Thanks for the quick fix @ije Unfortunately it's still not fixed for me requesting this URL: https://esm.sh/react@18.2.0

tsirysndr commented 1 year ago

same problems with these packages : https://esm.sh/@dagger.io/dagger@0.6.3 https://esm.sh/express@4.18.2 https://esm.sh/yaml@2.3.1

thatcher-gaming commented 1 year ago

update: it appears to be broken again

smcardle commented 1 year ago

This affects loads of the libraries for instance

https://esm.sh/v89/htm@3.1.1

I literary have dozens of libraries affected

still returns scrambled data

ije commented 1 year ago

updated, can you please try again?

smcardle commented 1 year ago

Every request for an esm.sh library from my code is now resulting in a 502

mkeftz commented 1 year ago

Seems to be working for me now, although required a force refresh. Thank you for your quick response 🙏

smcardle commented 1 year ago

Definitely still NOT working for instance.... https://esm.sh/v89/preact@10.10.0

This is just one of about 50 libraries I use and in the first request NONE of the initial 6 libraries required from esm.sh are working

esm.sh/v89/preact@10.10.0/compat esm.sh/v89/preact@10.10.0 esm.sh/v89/htm@3.1.1 esm.sh/v89/uuid@8.3.2 esm.sh/v89/rxjs@7.5.6/webSocket?external=rxjs esm.sh/v89/rxjs@7.5.6/operators?external=rxjs

ije commented 1 year ago

Definitely still NOT working

https://esm.sh/v89/preact@10.10.0

did you try to purge your browser/deno cache? seem it works for me now

Screenshot 2023-07-07 at 08 21 25
smcardle commented 1 year ago

OK. It is now working....

I have no reason to purge the cache as I run in dev tools mode with cache disabled

Anyway thanks for fixing and a bit of re-assurance this will not happen again would be good.

A discord server or something to report these types of issues and get a "conversation" going would be useful in the future. This kind of issue is a critical issue to some of us and knowing some of the devs are watching / online would be great.

Anyway, esm.sh is my favourite CDN but an explanation of what caused the issue so I can go back to my boss with a "why it happened" scenario would be great.

Also, why would this have affected older version i.e. v89 that were already available and cached ? I thought the whole point of the versioning is that older versions we depend on never get regenerated

ije commented 1 year ago

Let me explain a bit what happened.

In latest update, I updated the stable build version from v118 to latest(v112) to fix some invalid source map (#668) for react.

The testing was passed in github CI env, but i made a mistake to use a different KV that is used to store esm.sh modules at edge. since the new KV is empty the worker need to fetch the module from origin server, but I have no idea why CF worker's fetch get garbage content from the esm.sh origin server with correct headers. This doesn't happen in local/CI env.

To fix this, i have to added an isValidUTF8 function to check the content from origin server.

ije commented 1 year ago

A discord server or something to report these types of issues and get a "conversation" going would be useful in the future. This kind of issue is a critical issue to some of us and knowing some of the devs are watching / online would be great.

Discord server: https://discord.gg/XDbjMeb7pb Status page: https://esm.instatus.com

Also, why would this have affected older version i.e. v89 that were already available and cached ? I thought the whole point of the versioning is that older versions we depend on never get regenerated

I agree, this is why the version exists. The issue was caused by the cache layer not the build server, i didn't handle it careflully. I should change the KV config seriously in feature updates!

zzeleznick commented 1 year ago

Not sure if I'm also seeing a downstream effect due to these changes, but I'm now seeing Invalid Body for some packages in addition to 502 responses.

For one of my transitive dependencies (e.g. he) there's no longer any valid output (i.e. https://esm.sh/he@1.2.0)

nojaf commented 1 year ago

The problem is still ongoing for me in Europe. Getting 502's as well. It might be a caching problem at this point.

As a local workaround, I spun up a Docker container

docker run -p 9004:8080 -d --name esm ghcr.io/esm-dev/esm.sh:latest

http://localhost:9004/firebase@9.23.0/app works like a charm.

nojaf commented 1 year ago

Works again for me: image

Thanks to everyone involved!