Skip to content

confusing error message from v23.currentRuntime #213

@cosnicolaou

Description

@cosnicolaou

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.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions