Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Symbol support breaking change #5

Closed
MartyJRE opened this issue Feb 22, 2024 · 6 comments · Fixed by #6
Closed

Symbol support breaking change #5

MartyJRE opened this issue Feb 22, 2024 · 6 comments · Fixed by #6

Comments

@MartyJRE
Copy link

Would you consider changing the symbol support from 7d659e7 to an optional feature enabled by a flag of some kind?

I get the improvement this brings, however it creates a MAJOR change for libraries and projects that depend on traverse.

For example older versions of Loopback 4 use babel/traverse which depends on traverse. They specify any MINORs or PATCHes as OK with the ^ symbol in their package.json file. Since this feature wasn't released as a new MAJOR version, they may start using it. The interface never contained anything other than strings, so this breaks when iterating over data with symbols.

@ljharb
Copy link
Owner

ljharb commented Feb 22, 2024

Can you elaborate? Enumerable own symbols are rare; in what concrete case is this causing breakage for someone?

@MartyJRE
Copy link
Author

MartyJRE commented Mar 6, 2024

Loopback depends on traverse. They use it to walk REST connector objects.
This behavior is fine while all leaves of the object are non-symbol. However, nothing's stopping you from setting one of the leaves to another complex object.
In our project, which depends on both loopback and traverse, we include an instance of forever-agent in the tree. Forever agent likely contains request, response and other complex objects. These contain symbols.
Thus the new feature breaks dependant libraries who were expecting the interface to be string up until now.

@MartyJRE
Copy link
Author

MartyJRE commented Mar 6, 2024

https://github.com/loopbackio/loopback-connector-rest/blob/3d0ea7b8ff59050796c09a8d037eefc8835d0658/lib/template.js#L52

In this file, loopback-rest-connector expects the output of traverse to be string. They call RegExp.exec() on the item, which can now be a symbol. This crashes.

@ljharb
Copy link
Owner

ljharb commented Mar 6, 2024

That is… impressively convoluted, and I think technically and unfortunately makes it qualify as an actual breaking change.

likely contains request, response and other complex objects. These contain symbols.

can you confirm that they do, in fact, contain enumerable symbols?

If it's just theoretical, then I don't necessarily need to change anything, but if existing non-contrived code that worked before, breaks now, then I do.

@MartyJRE
Copy link
Author

MartyJRE commented Mar 7, 2024

This screenshot was taken in the debugger during the operation I described:

image

It seems the agent doesn't contain a request and response as I thought. However, it does contain its own symbols.

@MartyJRE
Copy link
Author

MartyJRE commented Mar 7, 2024

I filed an issue with loopback as well, but I feel like this needs to be fixed in both places.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants