denoland / deno

A modern runtime for JavaScript and TypeScript.
https://deno.com
MIT License
94.66k stars 5.25k forks source link

Granular unstable feature flags appear ignored #21434

Closed jcayzac closed 10 months ago

jcayzac commented 10 months ago

Version: Deno 1.38.3

I added this entry to my deno.jsonc:

"unstable": [
  "broadcast-channel",
  "ffi",
  "fs",
  "kv",
  "net",
  "http",
  "worker-options",
  "cron"
],

…and stopped passing --unstable to the CLI, but now I'm getting errors:

error: ReferenceError: BroadcastChannel is not defined

The schema only has:

"unstable": {
  "type": "array",
  "description": "List of unstable features to enable.",
  "items": {
    "type": "string"
  }
}

The feature name broadcast-channel is correct according to the crate's source code, and from what I understand of the feature_checker code it should work.

Moreover, passing --unstable-broadcast-channel on the command line results in the exact same error.

Granular unstable feature flags appear ignored, either on the command line or in the configuration file.

bartlomieju commented 10 months ago

The problem is here: https://github.com/denoland/deno/blob/0f990d9d927a0b25bc0eac32f2e7eee7c0460693/runtime/js/99_main.js#L497-L499

BroadcastChannel and WebSocketStream are only made available in the global scope if --unstable flag is passed, but ignored for granular flags.