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

Socket child can fail to initialize due to className mismatch #74

Open
Abrahamic-God opened this issue Mar 1, 2020 · 8 comments
Open
Assignees
Labels
bug Something isn't working

Comments

@Abrahamic-God
Copy link
Contributor

Abrahamic-God commented Mar 1, 2020

  • I'm submitting a ...
    [x] bug report
    [ ] feature request
    [ ] question about the decisions made in the repository
    [ ] question about how to use this project

  • Summary
    At src/lib/atemSocket.ts#L114, the name of the AtemSocketChild class can sometimes be a mangled/minified string, such as the single letter c.

    Later, when threadedClass@src/internalApi.ts#L296 loads the same module, it tries to find a class named c on the module export, which does not exist, because the actual class name is AtemSocketChild. This results in the following error being printed:

    INIT error {}
    
  • Other information
    This is when running on a Tessel 2 which runs Node v8.11.3, I haven't tested any other platforms or Node versions.

    I don't actually know how or where this mangling of the class name occurs, nor why.

@Abrahamic-God Abrahamic-God added the bug Something isn't working label Mar 1, 2020
@Abrahamic-God
Copy link
Contributor Author

Ok, so the root cause is that the build process that the Tessel uses does indeed apply a minification step, and I guess threadedClass can fall apart when anything that mangles symbol names is used.

@Julusian
Copy link
Member

Julusian commented Mar 1, 2020

Yeah, that sounds like the cause. I'm not sure on how this could be resolved, any minification that mangles exported names might trigger this?
@nytamin any thoughts?

@Julusian
Copy link
Member

Julusian commented Mar 1, 2020

Except, that surely both the caller and module side should be minified to have the same names so it should still line up?
Could you send me an example of what the minified code looks like? (a PM over slack is good)

@Abrahamic-God
Copy link
Contributor Author

The problem is that the export is still AtemSocketChild, but the class name gets mangled. threadedClass currently expects that these two things are always identical.

@Julusian
Copy link
Member

Julusian commented Mar 1, 2020

For my memory: the threadedClass PR will help with this issue. There is another issue with the library getting confused after minification whenever we use .constructor.name

@Abrahamic-God
Copy link
Contributor Author

Running my tessel with --compress=false seems to at least help somewhat alleviate this issue for now.

@Julusian Julusian self-assigned this Jun 24, 2020
@Julusian
Copy link
Member

This is resolved in 2.0.0-nightly-20200626-195656-eb05a5c.0.
But there is still some work needed inside this library to remove other useages of .constructor.name

@sensslen
Copy link

sensslen commented Mar 9, 2021

Hi, I tried using atem-connection in combination with webpack (using electron) to build a one click application. I assume this issue is the reason the application fails badly.

So my Question would be: Whether there is any chance for this issue to be fixed completely in the near future?

Digging deeper, I guess the issue I have is not related --> see #106

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants