worker-dom icon indicating copy to clipboard operation
worker-dom copied to clipboard

Debug: Warn on unsupported properties with Proxy

Open dreamofabear opened this issue 6 years ago • 6 comments

For debug mode only, it might be nice to add a JS proxy that warns when setting unsupported properties. E.g. with a short-link to new issue template for worker-dom.

Thinking about the easiest way to integrate this. If we go with the separate debugging module fetched at runtime, we'd need one for the worker and one for the main-thread. Maybe another output variant is justified? 🤔

dreamofabear avatar Oct 31 '18 16:10 dreamofabear

We've implemented the extra output option that enables more debugging knowledge and capabilities. Howeverm this feature will take time to complete, do you think we should prioritize it or drop the idea for now?

kristoferbaxter avatar Aug 25 '19 04:08 kristoferbaxter

Low priority but let's keep it open. Using unsupported properties may cause non-obvious downstream bugs e.g. undefined being passed around and causing something else to break.

dreamofabear avatar Aug 26 '19 15:08 dreamofabear

bumping this given todays standup discussion

Is a development build the best path forward?

patrickkettner avatar Jan 21 '20 22:01 patrickkettner

If Proxy implementation for this is small enough, might be sufficient to have a runtime check (e.g. enabled via hash param on window location) rather than compile-time via separate binary.

dreamofabear avatar Jan 21 '20 23:01 dreamofabear

new Proxy(thingWeWrap, {
  get(thingWeWrap, prop, receiver) {
    if (!(prop in thingWeWrap) {
      // warn
    }
    return Reflect.get(thingWeWrap, prop, receiver);
  }
});

It becomes more complicated if you need to recursively wrap, but since we control all the initial values, probably not necessary.

And if we need to trap delete, and getOwnPropertyDescriptor.

jridgewell avatar Jan 21 '20 23:01 jridgewell

In general having a development version of amp-script would allow us to provide more detail and useful error messaging than including debugging capabilities in the same binary.

I'd vote for using this as the starting place to introduce a development binary with the same set of browser support as the main binary.

kristoferbaxter avatar Jan 22 '20 00:01 kristoferbaxter