Parallelizing fosite handler processing?

Hi,

I am wondering if it would be reasonable to parallelize some or all fosite handler iteration. For example, fosite currently generates an access token and an ID token sequentially as we iterate through the relevant handlers here in access_response_writer.go

func (f *Fosite) NewAccessResponse(ctx context.Context, requester AccessRequester) (AccessResponder, error) {
    var err error
    var tk TokenEndpointHandler

    response := NewAccessResponse()
    for _, tk = range f.TokenEndpointHandlers {
	    if err = tk.PopulateTokenEndpointResponse(ctx, requester, response); err == nil {
	    	// do nothing
	    } else if errors.Is(err, ErrUnknownRequest) {
	    	// do nothing
	    } else if err != nil {
	    	return nil, err
	    }
    }

    if response.GetAccessToken() == "" || response.GetTokenType() == "" {
    	return nil, errorsx.WithStack(ErrServerError.WithHint("An internal server occurred while trying to complete the request.").WithDebug("Access token or token type not set by TokenEndpointHandlers."))
    }

    return response, nil
} 

Would there be an issue with spinning up a new goroutine to process each handler and wait until all are done before returning? Are some handlers dependent on others being done first?

Thanks

Yes, order is unfortunately required for some handlers to work properly!

Thanks, I just noticed this as well this morning when experimenting with implementing my own provider with Fosite as a base to override NewAccessResponse() and run the handlers in parallel; saw that the ID token actually requires the hash of the access token. Good to know!