question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`with (scopeProxy) { foo() }` leaks scopeProxy if foo mentions `this`.

See original GitHub issue

Typing valueOf() into the evaluator shim playground (demo/index.html) and hitting the Evaluate button causes the error

please report internal shim error: unexpected scope handler trap called: ownKeys

Unlike other surprising scopeProxy traps, this does not look like an engine bug. We see identical symptoms on Brave, FF, and Safari.

[edit by @kriskowal 2020-08-12:]

Actions needed (to be independently tracked, and this issue closed)

  • Create a specification proposal that introduces a hiddenWith symbol that with would respect.
  • Document this known-limitation of SES-shim, barring eventual engine support for a hiddenWith symbol.
  • Confirm that absent hiddenWith, revealing the ScopeProxy does not break containment.

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:1
  • Comments:10 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
allenwbcommented, Oct 27, 2019

(grr…it’s too easy to accidentally loose/close a github tab with an unsaved text entry field…trying again)

This should be easy (at least at the ECMA-262 spec. level) to fix. Object Environment Records already have a specification mechanism that controls whether or not they make their backing object available for inclusion in resolved References. This is controlled by the setting their withValue to true. With statements normally do that for all with objects. What we need to do is not set withValue to true when the with object is a ScopeProxy.

There are various ways this might be done in the spec, but I suggest doing all the work in with statement evaluation. Specifically we need to put a “not a ScopeProxy” guard on step 5 which currently unconditionally sets withValue.

What does the guard look like? We really don’t want to build knowledge of a specific ScopeProxy definition into this level of ECMA-262. Instead, I suggest we define a new well-known symbol named @@hiddenWith. The guard would be: HasOwnProperty(obj, @@hiddenWith) is false. The definition of ScopeProxy (its proxy handler) would ensure that they always report that they have a @@hiddenWith own property. That’s it!

Actually updating implementations to do this is probably not quite so simple, I assume that they don’t have anything that exactly corresponds to an Object environment record with a withValue flag. But I suspect that adapting an implementation to conform to this updated specification would be a modest effort—and well worth it.

1reaction
allenwbcommented, Oct 27, 2019

I left out of my redo: this ECMA-262 specification change appears be backwards compatible with all existing ES code.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Scoped-proxy memory leak w/ @Resource injection [SPR-9176]
This is because the proxy object representing the HttpServletRequest has a bean name like "$Proxy10@XXXXX" where XXXXX changes for each request. These entries ......
Read more >
spring scoped proxy bean - java - Stack Overflow
In our case, when a UserManager instance invokes a method on the dependency-injected UserPreferences object, it will really be invoking a method on...
Read more >
Spring - @Scope and scoped-proxy class based Example
This is another way to inject a short-lived scoped bean into long-lived scoped bean. For example injecting a prototype bean into a singleton...
Read more >
Weld: Documentation - Weld/CDI - CDI Spec
When a Weld-enabled application is deployed on an application server or a web server, proxy classes for beans implementing interfaces or extending classes ......
Read more >
Contexts and Dependency Injection - Quarkus
The CoolService is a normal scoped bean, so we have to invoke a method upon the injected proxy to force the instantiation. Annotate...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found