Okay, I’ve figured this out and it isn’t a Fly.io problem. It’s a Deno / esm.sh problem.
I debugged this more today to see if A) It was a transient problem (it wasn’t), and B) To get to the bottom of it if possible. Digging through the Monitoring tab, I found an error loading the Planetscale module because it didn’t match the hash in deno.lock
. And there’s a good reason for that: The content changed.
As I write this, getting https://esm.sh/@planetscale/database@1.8.0
returns this:
/* esm.sh - @planetscale/database@1.8.0 */
export * from "/v128/@planetscale/database@1.8.0/esnext/database.mjs";
…which in turn makes Deno load https://esm.sh/v128/@planetscale/database@1.8.0/denonext/database.mjs
.
But, my local workstation Deno cache for https://esm.sh/@planetscale/database@1.8.0
contained this instead:
/* esm.sh - @planetscale/database@1.8.0 */
export * from "/v127/@planetscale/database@1.8.0/esnext/database.mjs";
Note the v127
instead of v128
, despite the original URL being for a specific version (@1.8.0
).
The content changed without the URL changing (which is what deno.lock
is there to protect us from).
Removing the cache entries for https://esm.sh/@planetscale/database@1.8.0
(and anything else with @planetscale
) and rebuilding the deno.lock
updated the hash, and the module load worked on Fly.
So why did the content change? Because of versions of esbuild
apparently.
From the esm.sh FAQ:
Why I get The source code is invalid...
error in Deno?
Since Deno 1.18+ will generate the deno.lock
file for the dependencies, but esm.sh builds code with different version of esbuild when you imports modules from different build version. To fix this issue, please try to pin the build version like https://esm.sh/react?pin=v128
. Or use the CLI Script to manage the dependencies that will fix the build version automatically.
So that’s the answer, and the solution would appear to be to use their CLI script. (Or not use esm.sh.)