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

Suppress the error message "createTcpServer: address already in use" #194

Closed
yihui opened this issue Feb 8, 2019 · 2 comments · Fixed by #234
Closed

Suppress the error message "createTcpServer: address already in use" #194

yihui opened this issue Feb 8, 2019 · 2 comments · Fixed by #234
Milestone

Comments

@yihui
Copy link
Member

yihui commented Feb 8, 2019

Is there a way to suppress this error message? For example, it may show up when shiny looks for a random port: https://github.com/rstudio/shiny/blob/8ae31eb/R/server.R#L742 but the error message is not really useful to users.

yihui added a commit to rstudio/pagedown that referenced this issue Feb 14, 2019
…error message "createTcpServer: address already in use", which is currently impossible to suppress: rstudio/httpuv#194
@schloerke
Copy link
Collaborator

Reprex:

srv1 <- httpuv::startServer("127.0.0.1", 12345, list())

errorMessage <- capture.output({
  tryCatch(
    {
      srv2 <- httpuv::startServer("127.0.0.1", 12345, list()) 
    }, 
    error = function(e) ""
  )
}, type = "message")
#> createTcpServer: address already in use
#> [1] ""
errorMessage
#> character(0)

?capture.output

Messages sent to ‘stderr()’ (including those from ‘message’,
‘warning’ and ‘stop’) are captured by ‘type = "message"’. Note
that this can be “unsafe” and should only be used with care.

@wch
Copy link
Collaborator

wch commented Feb 22, 2019

I think the reason it can't be suppressed is because the message comes from a separate thread.

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

Successfully merging a pull request may close this issue.

3 participants