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

Disable logging for babel require. #152

Open
luanon404 opened this issue Dec 5, 2024 · 5 comments
Open

Disable logging for babel require. #152

luanon404 opened this issue Dec 5, 2024 · 5 comments

Comments

@luanon404
Copy link

Here is my error:

☕  JavaScript Error  Call to 'default' failed:  
> traverse(ast, {  
  at <module> (.../Playground/babel.py:13)  
>  

... across the bridge ...  

  at TraversalContext.visitSingle (.../@babel/traverse/lib/context.js:66:19)  
  at TraversalContext.visitQueue (.../@babel/traverse/lib/context.js:90:16)  
  at NodePath.visit (.../@babel/traverse/lib/path/context.js:95:52)  
  at traverseNode (.../@babel/traverse/lib/traverse-node.js:22:17)  
  at TraversalContext.visit (.../@babel/traverse/lib/context.js:113:19)  
  at TraversalContext.visitSingle (.../@babel/traverse/lib/context.js:66:19)  
  at TraversalContext.visitQueue (.../@babel/traverse/lib/context.js:90:16)  
  at NodePath.visit (.../@babel/traverse/lib/path/context.js:89:31)  
  at NodePath.call (.../@babel/traverse/lib/path/context.js:40:18)  
  at NodePath._call (.../@babel/traverse/lib/path/context.js:52:13)  

> throw new Error(`You appear to be using a plugin with an async traversal visitor, ` + `which your current version of Babel does not support. ` + `If you're using a published plugin, you may need to upgrade ` + `your @babel/core version.`);  

🌉 Error: You appear to be using a plugin with an async traversal visitor, which your current version of Babel does not support. If you're using a published plugin, you may need to upgrade your @babel/core version.  

if i use version="latest", i got:

☕  JavaScript Error  Call to 'require' failed:  
> traverse = require("@babel/traverse", version="latest").default  
  at <module> (.../Playground/babel.py:8)  
>  

... across the bridge ...  

  at Readable.push (node:internal/streams/readable:375:5)  
  at readableAddChunkPushByteMode (node:internal/streams/readable:495:3)  
  at addChunk (node:internal/streams/readable:545:12)  
  at Socket.emit (node:events:514:28)  
  at Socket.<anonymous> (.../javascript/js/bridge.js:292:18)  
  at Bridge.onMessage (.../javascript/js/bridge.js:231:25)  
  at Bridge.call (.../javascript/js/bridge.js:136:42)  
  at Object.$require [as require] (.../javascript/js/deps.js:128:22)  
  at PackageManager.install (.../javascript/js/deps.js:63:35)  
  at PackageManager.getInstalledVersion (.../javascript/js/deps.js:41:39)  
  **TypeError: Cannot read properties of undefined (reading '@babel/traverse')**  

🌉 **TypeError:** Cannot read properties of undefined (reading '@babel/traverse')  

or

☕  **JavaScript Error** Call to 'require' failed:  
> `traverse = require("@babel/traverse@latest").default`  
  at <module> (.../Playground/babel.py:8)  
>  

... across the bridge ...  

  at Readable.push (node:internal/streams/readable:375:5)  
  at readableAddChunkPushByteMode (node:internal/streams/readable:495:3)  
  at addChunk (node:internal/streams/readable:545:12)  
  at Socket.emit (node:events:514:28)  
  at Socket.<anonymous> (.../javascript/js/bridge.js:292:18)  
  at Bridge.onMessage (.../javascript/js/bridge.js:231:25)  
  at Bridge.call (.../javascript/js/bridge.js:136:42)  
  at Object.$require [as require] (.../javascript/js/deps.js:128:22)  
  at PackageManager.install (.../javascript/js/deps.js:63:35)  
  at PackageManager.getInstalledVersion (.../javascript/js/deps.js:41:39)  
  **TypeError: Cannot read properties of undefined (reading '@babel/traverse@latest')**  

🌉 **TypeError:** Cannot read properties of undefined (reading '@babel/traverse@latest')  

I have no problem with the code, but there is anyway to disable error for this call?

@extremeheat
Copy link
Owner

I advise you instead name the package something else when installing, as to avoid issues with JSPyBridge's parsing.

python -m javascript install babel-traverse@npm:@babel/traverse will allow you to require the package with just require('babel-traverse').

@luanon404
Copy link
Author

I advise you instead name the package something else when installing, as to avoid issues with JSPyBridge's parsing.

python -m javascript install babel-traverse@npm:@babel/traverse will allow you to require the package with just require('babel-traverse').

thanks for response, i dont get it, the docs dont say anything about that, i will try later, hope its working, i will reply after testing

@luanon404
Copy link
Author

I advise you instead name the package something else when installing, as to avoid issues with JSPyBridge's parsing.

python -m javascript install babel-traverse@npm:@babel/traverse will allow you to require the package with just require('babel-traverse').

hi again, i tried, but i still got same error, i tested package with nodejs script, all good, so this maybe some mistake here, can you check about it?

@luanon404
Copy link
Author

that code still working if i put it in threading

threading.Thread(target=traverse, args=(ast, {
    "VariableDeclarator": collect_function_bodies,
}), daemon=True).start()

so this is only solution i know right now

@luanon404
Copy link
Author

or better that

def proxy_run(function, *args, **kwargs):
    try:
        return function(*args, **kwargs)
    except Exception:
        pass

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

No branches or pull requests

2 participants