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

Getting "is not a function" error with node-library build, but only in specific situations/locations #849

Closed
bpringe opened this issue Mar 5, 2021 · 8 comments
Labels
cannot reproduce cannot reproduce described issue, will close after a while

Comments

@bpringe
Copy link
Sponsor

bpringe commented Mar 5, 2021

This is something I've been troubleshooting for a while now. As per our recent discussions I've stuck to the :node-library target for Calva. I'll try to explain this as simply as possible. I just want to see if you happen to know off hand what's going on.

I've found that calling functions exported from the shadow-cljs build does not work only in a particular place in our code base. For example, in this particular file/function, if we call parseForms, which is required from our cljs library, when Calva loads this call is executed and we get an error: cljs_lib_1.parseForms is not a function.

This call, however, works in other files/locations. I can move it up one level into the code that calls this updateREPLSessionType function, and it works. This is really strange to me.

I may be able to refactor to work around it by just not calling the cljs library functions from that location, but I like to know why things aren't working, and it's a bit concerning that maybe this could pop up elsewhere.

@bpringe
Copy link
Sponsor Author

bpringe commented Mar 5, 2021

Another thing to note is that it works fine with a release build of the cljs. I only see this error when running a watch on the build for development.

@thheller
Copy link
Owner

Sorry I cannot tell what the code is doing. The location you linked doesn't seem to be anywhere close to the use of the parseForms function so I don't have a clue how that is related.

Without a reproducible example I cannot help.

@thheller thheller added the cannot reproduce cannot reproduce described issue, will close after a while label Mar 11, 2021
@bpringe
Copy link
Sponsor Author

bpringe commented Mar 11, 2021

I just meant if parseForms were called there, not that it is. I was giving an example of what doesn't work.

I've worked around the issue by exporting our cljs library from our utilities.ts module, where calls work well, and then in those trouble files where direct calls don't work (just a couple that I've noticed thus far), I import the cljs library from the utilities module and calling functions from that works (just not if I import the cljs lib directly and call the functions).

It's some kind of weird linking issue it seems, but I'm guessing it's not anything caused by shadow. Closing this now. Thanks, though!

@bpringe bpringe closed this as completed Mar 11, 2021
@bpringe
Copy link
Sponsor Author

bpringe commented Mar 11, 2021

This is what I meant by the utilities proxy thing above, that works, just fyi: https://github.com/BetterThanTomorrow/calva/blob/86151d702f844136082dc3c41d7e8c719f9869ea/src/namespace.ts#L47

@bpringe
Copy link
Sponsor Author

bpringe commented Mar 15, 2021

Opening this back up and providing a repro, as it continues to give me trouble. I made a separate branch with a repro case: https://github.com/BetterThanTomorrow/calva/tree/cljs_issue_repro. The steps to be performed on that branch:

  1. Run npx vsce package - which runs the release script in package.json
  2. Open a Clojure project in VS Code and install the vsix just created. From the command pallet, run Extensions: Install from VSIX...
  3. In the status bar in the bottom left you'll see a message about clojure-lsp initializing. Once that's complete, hover over a symbol in a clojure doc, notice no hover information appears.
  4. Go to Help -> Toggle Developer Tools. See an error in the console like:
    ERR m.getStateValue is not a function: TypeError: m.getStateValue is not a function
    at Object.n.getConnectedState
    

The above error is happening in this function, which is being called from here when you hover over a symbol.

You can see this function is exported in our shadow config. It works in some cases, and not in others. And some of the other exported function calls have also thrown that error, whereas calls to those same functions in other locations work. I haven't found a pattern yet to hint at a cause.

In the past I was getting this error during development, with not bundled output, but the bundled-with-webpack output worked. However, now it works in development, but the errors show up in the bundled output. So, from my perspective it's really strange, but I really hope the fix is something simple I'm just missing. 😄

@bpringe bpringe reopened this Mar 15, 2021
@thheller
Copy link
Owner

Sorry but this is far too much code and setup required for me to look at. I have none of those tools installed and cannot simply run this.

It looks fine config wise but I don't have a clue what is going on in the code.

@bpringe
Copy link
Sponsor Author

bpringe commented Mar 15, 2021

Ah, okay. Well, in any case thanks for all you've done with this project! I still have hope I can work more cljs into Calva. I'll keep working at it.

@bpringe bpringe closed this as completed Mar 15, 2021
@thheller
Copy link
Owner

Please remember that :node-library is tailored towards NODE libraries so it is fully expected to have some issue in other not-actually-node type setups. I do not know how vscode plugins are actually bundled and loaded or what the runtime looks like so maybe it is a simple issue but I cannot tell.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cannot reproduce cannot reproduce described issue, will close after a while
Projects
None yet
Development

No branches or pull requests

2 participants