Effect CommunityEC
Effect Communityβ€’2y agoβ€’
7 replies
addamsson

Error in `makeTag` function with stack trace limit

I've just tried to print a Tag and I've found a stack in it that has an error. What's the intent of this?
export const makeTag = <Identifier, Service = Identifier>(identifier?: unknown): C.Tag<Identifier, Service> => {
  if (identifier && tagRegistry.has(identifier)) {
    return tagRegistry.get(identifier)!
  }
  const limit = Error.stackTraceLimit
  Error.stackTraceLimit = 2
  const creationError = new Error()
  Error.stackTraceLimit = limit
  const tag = Object.create(TagProto)
  Object.defineProperty(tag, "stack", {
    get() {
      return creationError.stack
    }
  })
  if (identifier) {
    tag.identifier = identifier
    tagRegistry.set(identifier, tag)
  }
  return tag
}

I can create a tag without a problem, but it still has a stack with an error in it πŸ˜…
Was this page helpful?