sst / ion

❍ — a new engine for SST
https://ion.sst.dev
MIT License
1.12k stars 136 forks source link

sst dev Does Not Reload Cloudflare Workers #321

Closed Ernxst closed 2 months ago

Ernxst commented 2 months ago

sst dev (version 0.0.322) does not reload a function that imports from cloudflare:workers (related to #256).

Steps to reproduce:

  1. Clone repo*
  2. Set environment variables and install providers (with sst install)
  3. Run sst dev
  4. Make a change to packages/functions/src/workerB.ts
  5. Make a change to packages/functions/src/workerA.ts

* Using a patch until #239 is in a release.

Any changes to workerB.ts will not trigger a reload, whereas a change to workerA.ts will. Found this out after observing none of my workers were being updated when I changed the code and then ran sst dev --verbose and observed the following log:

time=2024-04-27T14:43:21.609+01:00 level=INFO msg="building function" runtime=worker functionID=WorkerB
time=2024-04-27T14:43:21.609+01:00 level=INFO msg="loader info" loader=map[]
time=2024-04-27T14:43:21.673+01:00 level=ERROR msg="esbuild error" error="{ID: PluginName: Text:Could not resolve \"cloudflare:workers\" Location:0x14000cd6300 Notes:[{Text:You can mark the path \"cloudflare:workers\" as external to exclude it from the bundle, which will remove this error and leave the unresolved path in the bundle. Location:<nil>}] Detail:<nil>}"
time=2024-04-27T14:43:21.673+01:00 level=INFO msg="function built" runtime=worker functionID=WorkerB

Which is an esbuild error - clearly SST is using a different esbuild config (than the one in my sst.config.ts) to check whether the worker needs a redeploy. Interestingly, the file change events are still picked up after any changes but sst does nothing with the last log being:

time=2024-04-27T14:43:53.370+01:00 level=INFO msg="checking if function should be rebuilt" runtime=worker functionID=WorkerB file=/Users/ernest/Downloads/sst-dev-issue/packages/functions/src/workerB.handler.ts
time=2024-04-27T14:43:53.370+01:00 level=INFO msg="checking if function should be rebuilt" runtime=worker functionID=WorkerA file=/Users/ernest/Downloads/sst-dev-issue/packages/functions/src/workerB.handler.ts

After that, nothing happens. It will still redeploy WorkerA after I start modifying workerA.ts, but any changes to workerB.ts are picked up, but stop at the log above without redeploying.

thdxr commented 2 months ago

fixed in v0.0.328