fastly / js-compute-runtime

JavaScript SDK and runtime for building Fastly Compute applications
https://developer.fastly.com/learning/compute/javascript/
Apache License 2.0
199 stars 26 forks source link

allowDynamicBackends(); has no affect on Dynamic Backends. #800

Closed alex8bitw closed 3 months ago

alex8bitw commented 3 months ago

Using v3.15.0 of js-compute on Fastly, with Dynamic Backend support enabled:

It seems allowDynamicBackends(false); or allowDynamicBackends(true); do nothing.

guybedford commented 3 months ago

With allowDynamicBackends(false) all calls to fetch must have a backend property provided. If you are finding this is not the case, can you share a code example of how you are able to achieve this?

alex8bitw commented 3 months ago

Here's a Fiddle: https://fiddle.fastly.dev/fiddle/a1152147 Note that the Fiddle works as it's supposed to. No backend is setup when allowDynamicBackends(false); But I find that when I actually upload the Compute code, this value is ignored.

Let me know if you're able to replicate.

guybedford commented 3 months ago

@alex8bitw when you say "ignored" do you mean that the application you've provided in the fiddle works correctly on compute instead of failing?

alex8bitw commented 3 months ago

I went over the code, and I believe I see the issue. I was setting allowDynamicBackends(false) in a global scope, but I was also setting the following in a local scope:

allowDynamicBackends({ connectTimeout: global_connectTimeout, firstByteTimeout: global_firstByteTimeout, betweenBytesTimeout: global_betweenBytesTimeout, });

The dynamic timeout config overrides the allowDynamicBackends(false), this seems to be by design.

guybedford commented 3 months ago

That is correct, the default behaviour is for dynamic backends to be disabled. When calling allowDynamicBackends with a value other than false, they are enabled.