Troubleshooting
Project builds successfully, but does not start
In most cases, issues running Shiny code with nhyris
are related to the R environment.
Because nhyris
uses an independent R environment, your Shiny app may work in Positron, RStudio, or VS Code, but not in nhyris
.
Common causes include different R versions or missing package dependencies.
To diagnose R-related issues, follow these steps:
- Navigate to your project directory (e.g.,
<Myapp>
). - Open
src/process-manager.js
. - Around line 42, modify the code as follows:
// To enable terminal output for debugging the R Shiny process:
// Change this line in src/process-manager.js (around L42):
// stdio: "ignore",
// To this:
: "inherit", stdio
This will display logs from the Shiny application in your IDE’s terminal.
Example Logs
Here is an example log output:
>
> .libPaths(r_lib_paths) # Temporarily set library paths to R_LIB_PATHS
>
> if (!requireNamespace("shiny", quietly = TRUE)) {
+ stop("The 'shiny' package is not installed in R_LIB_PATHS: ", r_lib_paths)
+ }
> shiny_dir <- Sys.getenv("RE_SHINY_PATH")
>
> shiny::runApp(
+ appDir = shiny_dir,
+ host = "127.0.0.1",
+ launch.browser = FALSE,
+ port = 1124
+ )
Loading required package: shiny
...
Error: `server` must be a function
...
Error checking server status: TypeError: fetch failed
at node:internal/deps/undici/undici:13510:13
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async checkServerStatus (/Users/jinhwan/Documents/GitHub/nhyris/ex39/src/index.js:34:17)
at async tryStartWebserver (/Users/jinhwan/Documents/GitHub/nhyris/ex39/src/index.js:139:24)
at async App.<anonymous> (/Users/jinhwan/Documents/GitHub/nhyris/ex39/src/index.js:253:5) {
[cause]: Error: connect ECONNREFUSED 127.0.0.1:1124
at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1611:16) {
errno: -61,
code: 'ECONNREFUSED',
syscall: 'connect',
address: '127.0.0.1',
port: 1124
}
}
This log can be divided into three parts:
1. R Execution
This section shows the R and Shiny startup process. These lines are not errors.
>
> .libPaths(r_lib_paths) # Temporarily set library paths to R_LIB_PATHS
>
> if (!requireNamespace("shiny", quietly = TRUE)) {
+ stop("The 'shiny' package is not installed in R_LIB_PATHS: ", r_lib_paths)
+ }
> shiny_dir <- Sys.getenv("RE_SHINY_PATH")
>
> shiny::runApp(
+ appDir = shiny_dir,
+ host = "127.0.0.1",
+ launch.browser = FALSE,
+ port = 1124
+ )
: shiny
Loading required package
...
2. Application Error
This section shows an error in your Shiny application. You need to investigate and fix the cause.
: `server` must be a function Error
For example, in this case, the server
object was incorrectly assigned:
<- fluidPage(...)
ui <- ui
server shinyApp(ui = ui, server = server)
3. Connection Error
This section shows connection attempts from Electron to the Shiny server.
nhyris
works in two parts:
- Runs the Shiny application on localhost:1124 using R.
- Connects to the Shiny application from Electron.
The Shiny app may take some time to start. Both processes are initiated almost simultaneously, so connection errors like the following may appear at first:
Error checking server status: TypeError: fetch failed
...
[cause]: Error: connect ECONNREFUSED 127.0.0.1:1124
...
If you see this error only a few times, it is normal—Electron will retry until the Shiny app is ready.
However, if you see this error more than 10 times, you should check and fix your Shiny application.
Made by jahnen