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

NodeCall crashes upon import with Julia 1.8.1 #9

Closed
Petter-s opened this issue Nov 13, 2022 · 9 comments
Closed

NodeCall crashes upon import with Julia 1.8.1 #9

Petter-s opened this issue Nov 13, 2022 · 9 comments

Comments

@Petter-s
Copy link

Julia version 1.8.2
NodeCall version v1.0.0
OS: kubuntu
Node version: v12.22.9

When I try to use the NodeCall package, it crashes on import. For example, when I type “using NodeCall” in julia, I get the following error:

ERROR: InitError: NodeError: Unexpected end of input 
Stacktrace: 
 [1] throw_error(env::NodeCall.NapiTypes.NapiEnv) 
   @ NodeCall ~/.julia/packages/NodeCall/elRVM/src/utils.jl:77 
 [2] macro expansion 
   @ ~/.julia/packages/NodeCall/elRVM/src/utils.jl:41 [inlined] 
 [3] (::NodeCall.var"#27#28")() 
   @ NodeCall ~/.julia/packages/NodeCall/elRVM/src/eval.jl:60 
 [4] with_result(f::NodeCall.var"#27#28", type::NodeCall.ResultType; this::Nothing) 
   @ NodeCall ~/.julia/packages/NodeCall/elRVM/src/eval.jl:11 
 [5] with_result 
   @ ~/.julia/packages/NodeCall/elRVM/src/eval.jl:9 [inlined] 
 [6] node_eval(script::String, result::NodeCall.ResultType; context::Nothing) 
   @ NodeCall ~/.julia/packages/NodeCall/elRVM/src/eval.jl:59 
 [7] ensure_dynamic_import(path::String; context::Nothing) 
   @ NodeCall ~/.julia/packages/NodeCall/elRVM/src/import.jl:87 
 [8] ensure_dynamic_import (repeats 2 times) 
   @ ~/.julia/packages/NodeCall/elRVM/src/import.jl:76 [inlined] 
 [9] initialize(env::Nothing; node_args::Vector{String}) 
   @ NodeCall ~/.julia/packages/NodeCall/elRVM/src/env.jl:56 
[10] initialize (repeats 2 times) 
   @ ~/.julia/packages/NodeCall/elRVM/src/env.jl:34 [inlined] 
[11] __init__() 
   @ NodeCall ~/.julia/packages/NodeCall/elRVM/src/env.jl:90 
[12] _include_from_serialized(pkg::Base.PkgId, path::String, depmods::Vector{Any}) 
   @ Base ./loading.jl:831 
[13] _require_search_from_serialized(pkg::Base.PkgId, sourcepath::String, build_id::UInt64) 
   @ Base ./loading.jl:1039 
[14] _require(pkg::Base.PkgId) 
   @ Base ./loading.jl:1315 
[15] _require_prelocked(uuidkey::Base.PkgId) 
   @ Base ./loading.jl:1200 
[16] macro expansion 
   @ ./loading.jl:1180 [inlined] 
[17] macro expansion 
   @ ./lock.jl:223 [inlined] 
[18] require(into::Module, mod::Symbol) 
   @ Base ./loading.jl:1144 
during initialization of module NodeCall

I have tried to remove and reinstall NodeCall but it doesn’t help. Is NodeCall not working with newer Julia versions?

@sunoru
Copy link
Owner

sunoru commented Nov 14, 2022

Hi, thanks for the feedback! I am preparing to release a new version that works with the latest Julia & NodeJS (LTS) versions. Sorry for the inconvenience

@Petter-s
Copy link
Author

Petter-s commented Dec 6, 2022

Is this issue supposed to be resolved now? I see that something in this package was updated ~3 weeks ago but I still get the same error as before when trying to use the package.

I have updated Node to v18 and uninstalled and reinstalled NodeCall with Pkg.

Node version v18.12.1
julia version 1.8.2
[84d67a5e] NodeCall v1.0.0

@sunoru
Copy link
Owner

sunoru commented Dec 12, 2022

Hi sorry for the late reply. Can you try to update again? v1.1.0 has been released now and it's supposed to work on Linux/macOS platforms.

@Petter-s
Copy link
Author

Hi sorry for the late reply. Can you try to update again? v1.1.0 has been released now and it's supposed to work on Linux/macOS platforms.

I just tried it. If I start Julia from terminal and import NodeCall is seems to work now! At least it does not crash on import and it prints hello world.

uname:~$ julia 
              _ 
  _       _ _(_)_     |  Documentation: https://docs.julialang.org 
 (_)     | (_) (_)    | 
  _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help. 
 | | | | | | |/ _` |  | 
 | | |_| | | | (_| |  |  Version 1.8.2 (2022-09-29) 
_/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release 
|__/                   | 

julia> using NodeCall 
julia> node_eval("console.log('Hello, world!')") 
Hello, world!

However, when I try to do the same thing from a Julia session within VS code, it still crashes upon import complaining about files called “jl_gZrLFF.j” and “ noop.js”.

using NodeCall

ERROR: InitError: NodeError: Cannot find module '/media/uname/.../jl_gZrLFF.j'
Require stack:
- /media/uname/.../noop.js

Any ideas on how to solve that?

@sunoru
Copy link
Owner

sunoru commented Dec 12, 2022

Ah I guess it's because you need to do NodeCall.initialize() manually if you are not in an interactive environment?

I'll also look into it later.

@sunoru
Copy link
Owner

sunoru commented Dec 12, 2022

It looks weird since that filename should end in .js instead of .j. Did you accidentally edit the source file (NodeCall/src/import.jl)?

@Petter-s
Copy link
Author

Ah I guess it's because you need to do NodeCall.initialize() manually if you are not in an interactive environment?

I'll also look into it later.

I don’t think the problem is related to NodeCall.initialize() because my code crashes during the execution of using NodeCall. So I can literally have a Julia file containing just a single line with using NodeCall and it will still cause a crash. And I have not tampered with any of the NodeCall source files.

I have discovered a strange phenomena about the issue:

The test file I have been using is called “checkConnectionFromJulia.jl”, and when I run it in VS code it crashes even if it only contains a single line with using NodeCall.

However, if I copy the .jl file to another directory, without modifying it at all, it runs fine from within VS code!
It is if its the path name that is causing the issue. This is the full path name that causes the error:

“/media/pett3r/Projekt/SyncthingFolder/Diverse_Projekt/Blanda programeringsspråk/Nodejs from Julia/”

It is noteworthy that the path is long and contains both spaces and Scandinavian letters (å). However when I copy the .jl file to another path with a name that contains both spaces and Scandinavian letters, it still works, so it is still a mystery what the problem is.

Anyway, it seems the issue is solved by just working from a different path, so I will close the issue now, thanks for all the help!

Here is the full error given by VS code when it crashes in case you are interested:

ERROR: InitError: NodeError: Cannot find module '/media/pett3r/Projekt/SyncthingFolder/Diverse_Projekt/Blanda programeringsspråk/Nodejs from Julia/jl_PmR9Y9.j'
Require stack:
- /media/pett3r/Projekt/SyncthingFolder/Diverse_Projekt/Blanda programeringsspråk/Nodejs from Julia/noop.js
Stacktrace:
  [1] throw_error(env::NodeCall.NapiTypes.NapiEnv)
    @ NodeCall ~/.julia/packages/NodeCall/RHQTj/src/utils.jl:82
  [2] macro expansion
    @ ~/.julia/packages/NodeCall/RHQTj/src/utils.jl:46 [inlined]
  [3] (::NodeCall.var"#144#145"{Bool, Nothing, NodeCall.JsFunction{Nothing}})()
    @ NodeCall ~/.julia/packages/NodeCall/RHQTj/src/types/functions.jl:35
  [4] #with_result#25
    @ ~/.julia/packages/NodeCall/RHQTj/src/eval.jl:11 [inlined]
  [5] with_result
    @ ~/.julia/packages/NodeCall/RHQTj/src/eval.jl:9 [inlined]
  [6] #_#143
    @ ~/.julia/packages/NodeCall/RHQTj/src/types/functions.jl:14 [inlined]
  [7] ensure_dynamic_import(path::String; context::Nothing)
    @ NodeCall ~/.julia/packages/NodeCall/RHQTj/src/import.jl:90
  [8] ensure_dynamic_import (repeats 2 times)
    @ ~/.julia/packages/NodeCall/RHQTj/src/import.jl:76 [inlined]
  [9] initialize(env::Nothing; node_args::Vector{String})
    @ NodeCall ~/.julia/packages/NodeCall/RHQTj/src/env.jl:56
 [10] initialize (repeats 2 times)
    @ ~/.julia/packages/NodeCall/RHQTj/src/env.jl:34 [inlined]
 [11] __init__()
    @ NodeCall ~/.julia/packages/NodeCall/RHQTj/src/env.jl:90
 [12] _include_from_serialized(pkg::Base.PkgId, path::String, depmods::Vector{Any})
    @ Base ./loading.jl:831
 [13] _require_search_from_serialized(pkg::Base.PkgId, sourcepath::String, build_id::UInt64)
    @ Base ./loading.jl:1039
 [14] _require(pkg::Base.PkgId)
    @ Base ./loading.jl:1315
 [15] _require_prelocked(uuidkey::Base.PkgId)
    @ Base ./loading.jl:1200
 [16] macro expansion
    @ ./loading.jl:1180 [inlined]
 [17] macro expansion
    @ ./lock.jl:223 [inlined]
 [18] require(into::Module, mod::Symbol)
    @ Base ./loading.jl:1144
 [19] eval
    @ ./boot.jl:368 [inlined]
 [20] include_string(mapexpr::typeof(REPL.softscope), mod::Module, code::String, filename::String)
    @ Base ./loading.jl:1428
 [21] invokelatest(::Any, ::Any, ::Vararg{Any}; kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ Base ./essentials.jl:729
 [22] invokelatest(::Any, ::Any, ::Vararg{Any})
    @ Base ./essentials.jl:726
 [23] inlineeval(m::Module, code::String, code_line::Int64, code_column::Int64, file::String; softscope::Bool)
    @ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.38.2/scripts/packages/VSCodeServer/src/eval.jl:233
 [24] (::VSCodeServer.var"#66#70"{Bool, Bool, Bool, Module, String, Int64, Int64, String, VSCodeServer.ReplRunCodeRequestParams})()
    @ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.38.2/scripts/packages/VSCodeServer/src/eval.jl:157
 [25] withpath(f::VSCodeServer.var"#66#70"{Bool, Bool, Bool, Module, String, Int64, Int64, String, VSCodeServer.ReplRunCodeRequestParams}, path::String)
    @ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.38.2/scripts/packages/VSCodeServer/src/repl.jl:249
 [26] (::VSCodeServer.var"#65#69"{Bool, Bool, Bool, Module, String, Int64, Int64, String, VSCodeServer.ReplRunCodeRequestParams})()
    @ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.38.2/scripts/packages/VSCodeServer/src/eval.jl:155
 [27] hideprompt(f::VSCodeServer.var"#65#69"{Bool, Bool, Bool, Module, String, Int64, Int64, String, VSCodeServer.ReplRunCodeRequestParams})
    @ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.38.2/scripts/packages/VSCodeServer/src/repl.jl:38
 [28] (::VSCodeServer.var"#64#68"{Bool, Bool, Bool, Module, String, Int64, Int64, String, VSCodeServer.ReplRunCodeRequestParams})()
    @ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.38.2/scripts/packages/VSCodeServer/src/eval.jl:126
 [29] with_logstate(f::Function, logstate::Any)
    @ Base.CoreLogging ./logging.jl:511
 [30] with_logger
    @ ./logging.jl:623 [inlined]
 [31] (::VSCodeServer.var"#63#67"{VSCodeServer.ReplRunCodeRequestParams})()
    @ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.38.2/scripts/packages/VSCodeServer/src/eval.jl:225
 [32] #invokelatest#2
    @ ./essentials.jl:729 [inlined]
 [33] invokelatest(::Any)
    @ Base ./essentials.jl:726
 [34] macro expansion
    @ ~/.vscode/extensions/julialang.language-julia-1.38.2/scripts/packages/VSCodeServer/src/eval.jl:34 [inlined]
 [35] (::VSCodeServer.var"#61#62")()
    @ VSCodeServer ./task.jl:484
during initialization of module NodeCall

@sunoru
Copy link
Owner

sunoru commented Dec 13, 2022

Wow, thanks so much for the detailed description. I believe the special letters and the long path should be the cause. I'll look into that.

@sunoru
Copy link
Owner

sunoru commented Dec 13, 2022

The problem is caused by incorrectly converting strings that contain non-ascii characters. It's fixed now in v1.1.1 and you can update it 😄

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