Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wagenet opened this issue Oct 2, 2020 · 5 comments
Open

Comments

@wagenet
Copy link
Member

wagenet commented Oct 2, 2020

馃悶 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
@wagenet wagenet changed the title [Bug] Bug report [Bug] "Attempted to create a log for a path reference" hiding real error Oct 2, 2020
@wagenet
Copy link
Member Author

wagenet commented Oct 2, 2020

I have verified that this issue is introduced in Ember 3.19. Before that it gives an error about how it must be a function. I'm guessing that additional debugging was added for 3.19, which caused the issue.

@KalachevDev
Copy link

Hey! I've seen the same issue with glimmer component. I accidentally didn't pass callback to fn helper and instead of descriptive message about missing callback I've got: Attempted to create a log for a path reference

@mcfiredrill
Copy link
Contributor

Hey! I've seen the same issue with glimmer component. I accidentally didn't pass callback to fn helper and instead of descriptive message about missing callback I've got: Attempted to create a log for a path reference

Same issue, a descriptive error message would be nice here.

@rwjblue
Copy link
Member

rwjblue commented Oct 14, 2020

I think we just landed a fix for this over in #19195. I'll be working on a series of backports / releases over the next day or two to get it released.

@tracyalison11
Copy link

tracyalison11 commented Sep 27, 2021

I recently received the same error because I did not include mock actions in my test setup that the component was expecting. This made it very difficult to debug. Any insight into why this error gets thrown with a message that's unrelated to the issue?

@wagenet wagenet reopened this Sep 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants