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.

[labs/router] Compression mangling error

See original GitHub issue

Description

There is a bug in the way package @lib-labs/router is bundled, specifically in the way files are being mangled during compression.

In production mode (the default export resolution per package.json), the bundled code at runtime is not equivalent (and incorrect in this case) to its original.

Cause

The cause (intuitively) seems to be that the mangling during compression is done on a per-file basis:

// Routes.js defines t, which represents _childRoutes) as an empty array.
class Routes {
  this.t = []; // this._childRoutes = [];
  ...
}
// Router.js redefines t as the onclick overriding incorrectly the inherited field
class Router extends Routes {
  this.t=t=>{...} // this was this._onClick = (e) => {
  ...
}

Since Router extends Routes the code is no longer equivalent after compression.

Conclusion

Without looking at the specific processor used to compress the files (wireit I believe), seems that doing this process by file will create in this (and many other cases) unintended mangling overrides due to the lack of dependencies context.

Unwanted observation:

IMHO I found it odd that the package is being shipped “pre-compressed” as the default, since I believe that should be the responsibility of the consumer, but that’s up to the team to decide the rationale to do so 😃

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
diervocommented, Jun 17, 2022

Thanks for the quick turnaround! Really appreciate the good work 🙏

Oh I know what @justinfagnani will say, just wanted to poke the bear a little 😹

Read more comments on GitHub >

github_iconTop Results From Across the Web

Approach for library-specific mangling compression · Issue #70
libc++ is revising its ABI, at least for some of its clients, and is very interested in using new "catalog" substitutions for the...
Read more >
Link errors and name mangling in C++ with Visual Studio 2008
My problem occurs in both Release and Debug mode. In the Properties pane or my project, I have added the directory containing the...
Read more >
Name mangling - Wikipedia
In compiler construction, name mangling (also called name decoration) is a technique used to solve various problems caused by the need to resolve...
Read more >
New C++ name mangling option and pragma for XL C ... - IBM
Problem. Binaries built with the -qnamemangling=compat option and ... as distinct types and were not mangled using the compression scheme ...
Read more >
D's Newfangled Name Mangling | The D Blog
In that case, the program is likely to crash, since a character passed to the function will be interpreted as a string pointer...
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