Skip to content

Include original function names in the source map #1085

Open
@nevkontakte

Description

@nevkontakte

While GopherJS tends to name JS functions similar to the Go ones, the names in the stack trace don't match exactly, which tends to break code that expects particular formatting of the stack trace function names.

relevantCaller() in net/http package is the most recent example I came across:

// relevantCaller searches the call stack for the first function outside of net/http.
// The purpose of this function is to provide more helpful error messages.
func relevantCaller() runtime.Frame {
	pc := make([]uintptr, 16)
	n := runtime.Callers(1, pc)
	frames := runtime.CallersFrames(pc[:n])
	var frame runtime.Frame
	for {
		frame, more := frames.Next()
		if !strings.HasPrefix(frame.Function, "net/http.") {
			return frame
		}
		if !more {
			break
		}
	}
	return frame
}

There's also an obvious benefit to the debugging experience of being able to more easily identify functions in the call stack.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions