@@ -102,7 +102,6 @@ export interface CoreOptions {
102102 globalAsyncIO ?: boolean ;
103103 globalTimers ?: boolean ;
104104 globalRandom ?: boolean ;
105- proxyPrimitiveInstanceOf ?: boolean ;
106105}
107106
108107function mapMountEntries (
@@ -340,15 +339,6 @@ export class CorePlugin extends Plugin<CoreOptions> implements CoreOptions {
340339 } )
341340 globalRandom ?: boolean ;
342341
343- @Option ( {
344- type : OptionType . BOOLEAN ,
345- name : "proxy-primitive" ,
346- description : "Proxy primitives' instanceof (for WASM)" ,
347- logName : "Proxy Primitives' instanceof" ,
348- fromWrangler : ( { miniflare } ) => miniflare ?. proxy_primitive_instanceof ,
349- } )
350- proxyPrimitiveInstanceOf ?: boolean ;
351-
352342 readonly processedModuleRules : ProcessedModuleRule [ ] = [ ] ;
353343
354344 readonly upstreamURL ?: URL ;
@@ -483,76 +473,6 @@ export class CorePlugin extends Plugin<CoreOptions> implements CoreOptions {
483473 // could be used as an escape hatch if behaviour needs to be different
484474 // locally for any reason
485475 MINIFLARE : true ,
486-
487- // Object, Array, Promise, RegExp, Error, EvalError, RangeError,
488- // ReferenceError, SyntaxError, TypeError, URIError and Function are
489- // intentionally omitted. There's a trade-off here, ideally we'd like all
490- // these checks to pass:
491- //
492- // ```js
493- // import vm from "vm";
494- //
495- // const ctx1 = vm.createContext({ objectFunction: () => ({}) });
496- //
497- // vm.runInContext("({}) instanceof Object", ctx1); // true
498- // vm.runInContext("({}).constructor === Object", ctx1); // true
499- //
500- // vm.runInContext("objectFunction() instanceof Object", ctx1); // false
501- // vm.runInContext("objectFunction().constructor === Object", ctx1); // false
502- //
503- // const ctx2 = vm.createContext({ Object: Object, objectFunction: () => ({}) });
504- //
505- // vm.runInContext("({}) instanceof Object", ctx2); // false
506- // vm.runInContext("({}).constructor === Object", ctx2); // false
507- //
508- // vm.runInContext("objectFunction() instanceof Object", ctx2); // true
509- // vm.runInContext("objectFunction().constructor === Object", ctx2); // true
510- // ```
511- //
512- // wasm-bindgen (a tool used to make compiling Rust to WebAssembly easier),
513- // often generates code that looks like `value instanceof Object`.
514- // We'd like this check to succeed for both objects generated outside of
515- // the worker (e.g. KV), and inside user code. This is what the
516- // `proxyPrimitiveInstanceOf` option is for. It replaces `Object` with
517- // a proxy that overrides `Symbol.hasInstance` with a cross-realm check:
518- //
519- // ```js
520- // function isObject(value) {
521- // return value !== null && typeof value === "object";
522- // }
523- //
524- // const ObjectProxy = new Proxy(Object, {
525- // get(target, property, receiver) {
526- // if (property === Symbol.hasInstance) return isObject;
527- // return Reflect.get(target, property, receiver);
528- // },
529- // });
530- //
531- // const ctx3 = vm.createContext({
532- // Object: ObjectProxy,
533- // objectFunction: () => ({}),
534- // });
535- //
536- // vm.runInContext("({}) instanceof Object", ctx3); // true
537- // vm.runInContext("({}).constructor === Object", ctx3); // false
538- //
539- // vm.runInContext("objectFunction() instanceof Object", ctx3); // true
540- // vm.runInContext("objectFunction().constructor === Object", ctx3); // false
541- // ```
542- //
543- // The problem with this option (it used to be the default) is that the
544- // `constructor`/`prototype` checks fail. These are used quite a lot in
545- // JS, and this was the cause of several issues:
546- // - https://github.com/cloudflare/miniflare/issues/109
547- // - https://github.com/cloudflare/miniflare/issues/137
548- // - https://github.com/cloudflare/miniflare/issues/141
549- // - https://github.com/cloudflare/wrangler2/issues/91
550- //
551- // The new default behaviour (omitting `Object` completely) still has
552- // the issue `constructor`/`prototype`/`instanceof` checks for `Object`s
553- // created outside the sandbox (e.g. KV) would fail, but I think that's
554- // less likely to be an issue, since the return types are always known
555- // in those cases.
556476 } ;
557477
558478 // Process module rules if modules mode was enabled
0 commit comments