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

issue with setResourceName #356

Open
Losin6450 opened this issue Jun 22, 2024 · 3 comments
Open

issue with setResourceName #356

Losin6450 opened this issue Jun 22, 2024 · 3 comments

Comments

@Losin6450
Copy link

Losin6450 commented Jun 22, 2024

Code:
`

private static boolean debug = true;

private static final JavetEnginePool<NodeRuntime> pool;

static {
    pool = new JavetEnginePool<>(new JavetEngineConfig()
            .setAllowEval(true)
            .setAutoSendGCNotification(true)
            .setJSRuntimeType(JSRuntimeType.Node)
    );
}

private final Path file;


public Context(File file){
    this.file = file.toPath();
}

public Context(Path path){
    this.file = path;
}


@Override
public void run() {
        if (debug) System.out.println(this.file);
        if (!Files.exists(this.file)){
            try {
                Files.createDirectories(this.file.getParent());
                Files.createFile(this.file);
            } catch (IOException e){
                e.printStackTrace();
                return;
            }
        }
        try (JavetEngine<NodeRuntime> engine = (JavetEngine<NodeRuntime>) pool.getEngine()){
            try (NodeRuntime runtime = engine.getV8Runtime()){
                JavetBridgeConverter converter = new JavetBridgeConverter();
                runtime.setConverter(converter);
                JavetJVMInterceptor interceptor = new JavetJVMInterceptor(runtime);
                try (V8ValueGlobalObject globalObject = runtime.getGlobalObject()){
                    interceptor.register(globalObject);
                }
                runtime.getExecutor(this.file).setModule(true).executeVoid();
                runtime.await();
            }
        } catch (JavetException e) {
            e.printStackTrace();
        }
}

`

Error:
[13:23:03] [Server thread/WARN]: com.caoccao.javet.exceptions.JavetExecutionException: TypeError [ERR_INVALID_ARG_TYPE]: The "id" argument must be of type string. Received an instance of String [13:23:03] [Server thread/WARN]: at com.caoccao.javet.interop.V8Native.functionCall(Native Method) [13:23:03] [Server thread/WARN]: at com.caoccao.javet.interop.V8Runtime.functionCall(V8Runtime.java:1074) [13:23:03] [Server thread/WARN]: at com.caoccao.javet.interop.V8Internal.functionCall(V8Internal.java:107) [13:23:03] [Server thread/WARN]: at com.caoccao.javet.values.reference.V8ValueFunction.callExtended(V8ValueFunction.java:97) [13:23:03] [Server thread/WARN]: at com.caoccao.javet.values.reference.IV8ValueFunction.call(IV8ValueFunction.java:56) [13:23:03] [Server thread/WARN]: at com.caoccao.javet.interop.NodeRuntime.getNodeModule(NodeRuntime.java:136) [13:23:03] [Server thread/WARN]: at com.caoccao.javet.interop.NodeRuntime.getNodeModule(NodeRuntime.java:110) [13:23:03] [Server thread/WARN]: at com.caoccao.javet.interop.executors.IV8Executor.setResourceName(IV8Executor.java:230) [13:23:03] [Server thread/WARN]: at com.caoccao.javet.interop.executors.V8PathExecutor.<init>(V8PathExecutor.java:54) [13:23:03] [Server thread/WARN]: at com.caoccao.javet.interop.V8Runtime.getExecutor(V8Runtime.java:1400) [13:23:03] [Server thread/WARN]: at org.grakkit.core.Context.run(Context.java:63)

@Losin6450
Copy link
Author

i have tried different versions and none worked

@caoccao
Copy link
Owner

caoccao commented Jun 22, 2024

Please leave a repo that can reproduce this issue.

@Losin6450
Copy link
Author

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