Skip to content

[Bug] "Attempted to create a log for a path reference" hiding real error #19180

Open
@wagenet

Description

@wagenet

🐞 Describe the Bug

While running tests I encountered this message:

testem.js:967 Error: BUG: Attempted to create a log for a path reference, but no node exist for that reference
    at expect (util.js:159)
    at DebugRenderTree.logRenderStackForPath (index.js:4492)
    at EmberEnvironmentDelegate.getTemplatePathDebugContext (index.js:5176)
    at EnvironmentImpl.getTemplatePathDebugContext (runtime.js:1849)
    at fn (index.js:5984)
    at HelperRootReference.callback [as fn] (index.js:6005)
    at reference.js:231
    at runInAutotrackingTransaction (validator.js:83)
    at track (validator.js:690)
    at HelperRootReference.compute (reference.js:230)

🔬 Minimal Reproduction

https://codesandbox.io/s/nostalgic-einstein-jdsfm

😕 Actual Behavior

Upon further investigation the error is stems from an assert in the fn helper. In this case, our test did not pass the expected function which triggered this bit of code:

  if (DEBUG && typeof callbackRef[INVOKE] !== 'function') {
    let callback = callbackRef.value();
    assert(`You must pass a function as the \`fn\` helpers first argument, you passed ${callback === null ? 'null' : typeof callback}. ${env.getTemplatePathDebugContext(callbackRef)}`, typeof callback === 'function');
  }

Unfortunately, the effort to get more debug information is what causes the error, hiding the real error in the process. Ultimately, the error is from logRenderStackForPath which has the following code:

let node = expect(this.pathNodes.get(pathRef), 'BUG: Attempted to create a log for a path reference, but no node exist for that reference');

pathRef is callbackRef from the original assert and this.pathNodes.get(pathRef) returns undefined.

🤔 Expected Behavior

There are two issues I see here 1) maybe this shouldn't be returning undefined and 2) even if there is an error in getting debug information, we should catch it so it doesn't hide the real error.

🌍 Environment

  • Ember: 3.21.1

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions