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

confusing error message from v23.currentRuntime #213

Open
cosnicolaou opened this issue Jun 24, 2021 · 0 comments
Open

confusing error message from v23.currentRuntime #213

cosnicolaou opened this issue Jun 24, 2021 · 0 comments
Assignees

Comments

@cosnicolaou
Copy link
Contributor

cosnicolaou commented Jun 24, 2021

The v23 context functions (eg. WithNewPrincipal) rely on a storing a pointer to the currently initialized runtime in the context. This accessed by the initStateData.currentRuntime() method. This method checks to ensure that the runtime has been initialized, ie. is non-nil.

 if i.runtime == nil {
    panic(`Calling v23 method during runtime initialization.  You cannot
call v23 methods until after the runtime has been constructed.  You may
be able to move the offending caller to the Runtime.Init() method of your
runtime implementation.`)
}

However, the runtime may be nil under two circumstances:

  1. it has yet to be initialized, and the error message above makes sense
  2. the runtime's shutdown function (returned when it is created) has been called, in which case, the error message above is confusing.

Situation 2 can arise if a process has go routines that are still running when shutdown is called that attempt, for example, to make an RPC. Although this is an application programming error, the error message and v23 package code should be modified to distinguish the two cases.

@cosnicolaou cosnicolaou self-assigned this Jun 24, 2021
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

1 participant