zipkin-js: Error: Must be valid TraceId instance

After upgrading to version 0.18.5 of zipkin-instrumentation-restify and zipkin, I am getting the following error when the request to my server comes in with a traceId: “Error: Must be valid TraceId instance”.

I’ve narrowed the problem down to the following snippet of code in zipkin/tracer/index.js inside the join function

if (!(traceId instanceof TraceId)) {
    throw new Error('Must be valid TraceId instance');
}

This if is always resulting to false, after inspecting the traceid passed to this function, I found the following.

traceId parameter:

TraceId {
  _traceId: 'b7daf2ae1b9e2555',
  _parentId:
   { type: [Getter],
     present: [Getter],
     map: [Function: map],
     ifPresent: [Function: ifPresent],
     flatMap: [Function: flatMap],
     getOrElse: [Function: getOrElse],
     equals: [Function: equals],
     toString: [Function: toString] },
  _spanId: 'b7daf2ae1b9e2555',
  _sampled:
   { type: [Getter],
     present: [Getter],
     map: [Function: map],
     ifPresent: [Function: ifPresent],
     flatMap: [Function: flatMap],
     getOrElse: [Function: getOrElse],
     equals: [Function: equals],
     toString: [Function: toString] },
  _debug: false,
  _shared: false }

traceId instanceof TraceId_1: false traceId.constructor.name: TraceId TraceId_1.constructor.name: Function TraceId.constructor.name: Function

Please note: The usage of TraceId_1 is because that is the output produced after transpilation, and hence is what is being checked in the code when it is actually running.

if (!(traceId instanceof TraceId_1)) {
    throw new Error('Must be valid TraceId instance');
}

This issue only happens if the request is made with the traceid and spanid headers populated.

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 9
  • Comments: 20 (16 by maintainers)

Commits related to this issue

Most upvoted comments

https://github.com/openzipkin/zipkin-js/pull/328 introduced this, specifically f665dc3e3efe99760486ae404291a344c2406a92

looking into it and will put a patch up ASAP

Updated to 0.18.6, tested and everything looks fine. Thanks @adriancole for the fast resolution!

ps sorry about the TraceIdApocalypse