TypeError in assemble helpers - javascript

Despite not using the filter helper in a template a TypeError is preventing assemble completing. It looks like the options parameter isn't being passed or is being passed as undefined.
Here's the stack trace:
Warning: Cannot read property 'data' of undefined Use --force to continue.
TypeError: Cannot read property 'data' of undefined
at Object.helpers.filter (/home/tim/workspace/projects/severine/node_modules/assemble/node_modules/assemble-handlebars/node_modules/handlebars-helpers/lib/helpers/helpers-collections.js:357:15)
at Object.eval (eval at <anonymous> (/home/tim/workspace/projects/severine/node_modules/assemble/node_modules/assemble-handlebars/node_modules/handlebars/lib/handlebars/compiler/compiler.js:564:23), <anonymous>:41:50)
at Object.<anonymous> (/home/tim/workspace/projects/severine/node_modules/assemble/node_modules/assemble-handlebars/node_modules/handlebars/lib/handlebars/runtime.js:30:33)
at Object.search (/home/tim/workspace/projects/severine/node_modules/assemble/node_modules/assemble-handlebars/node_modules/handlebars/lib/handlebars/compiler/compiler.js:1274:21)
at Object.Handlebars.VM.invokePartial (/home/tim/workspace/projects/severine/node_modules/assemble/node_modules/assemble-handlebars/node_modules/handlebars/lib/handlebars/runtime.js:81:28)
at Object.eval (eval at <anonymous> (/home/tim/workspace/projects/severine/node_modules/assemble/node_modules/assemble-handlebars/node_modules/handlebars/lib/handlebars/compiler/compiler.js:564:23), <anonymous>:86:17)
at /home/tim/workspace/projects/severine/node_modules/assemble/node_modules/assemble-handlebars/node_modules/handlebars/lib/handlebars/runtime.js:30:33
at /home/tim/workspace/projects/severine/node_modules/assemble/node_modules/assemble-handlebars/node_modules/handlebars/lib/handlebars/compiler/compiler.js:1274:21
at Object.render (/home/tim/workspace/ae_projects/severine/node_modules/assemble/node_modules/assemble-handlebars/index.js:38:17)
at Object.render (/home/tim/workspace/projects/severine/node_modules/assemble/lib/engine.js:87:17)
Aborted due to warnings.
If I comment out the body of the filter function, assemble runs normally.

#tim we usually see these errors when there's a conflict with a property name on the data context and a handlebars helper.
If you have filter as a property in your data context, try using {{this.filter}} instead of {{filter}} to give Handlebars a hint that it should be using the property instead of the helper.
This question is from this issue on Github. I hope this helps anyone else having the same issue.

Related

How do I downgrade my ethers.js version from 5.7.2 to 5.6.1?

I'm building an NFT Marketplace demo. Whenever I try to click on 'Create an NFT' button, an Unhandled
Runtime Error pops up -
TypeError: Cannot read properties of undefined (reading 'length').
Call Stack
toUtf8Bytes
node_modules\#ethersproject\strings\lib.esm\utf8.js (176:20)
StringCoder.encode
node_modules\#ethersproject\abi\lib.esm\coders\string.js (12:47)
eval
node_modules\#ethersproject\abi\lib.esm\coders\array.js (49:0)
Array.forEach
<anonymous>
pack
node_modules\#ethersproject\abi\lib.esm\coders\array.js (43:0)
TupleCoder.encode
node_modules\#ethersproject\abi\lib.esm\coders\tuple.js (51:19)
AbiCoder.encode
node_modules\#ethersproject\abi\lib.esm\abi-coder.js (86:0)
Interface._encodeParams
node_modules\#ethersproject\abi\lib.esm\interface.js (253:0)
Interface.encodeFunctionData
node_modules\#ethersproject\abi\lib.esm\interface.js (295:0)
eval
node_modules\#ethersproject\contracts\lib.esm\index.js (125:0)
Generator.next
<anonymous>
fulfilled
node_modules\#ethersproject\contracts\lib.esm\index.js (5:42)
`
I tried to resolve it by two methods suggested online -
Make changes to Infura 'projectId' and 'projectSecret' in .env file and change the 'createitem' function in 'create-nft.js' as well.
Downgrade the ethers.js from current version to 5.6.1, as all the later versions cause problems with Hardhat. But I don't how to downgrade ethers.js and can't find a link where it is stated clearly how to do it.

Browserify with require('fs-extra') and upon loading bundle.js throws Uncaught TypeError: Object prototype may only be an Object or null: undefined

This issue is only specific to fs-extra module.
When i try to load browserified bundle.js in html, the error shows up.
bundle.js:2483 Uncaught TypeError: Object prototype may only be an Object or null: undefined
at Function.setPrototypeOf (<anonymous>)
at bundle.js:2483
at patch (bundle.js:2485)
at patch (bundle.js:1949)
at Object.<anonymous> (bundle.js:1941)
at Object.<anonymous> (bundle.js:2220)
at Object.31../clone.js (bundle.js:2220)
at o (bundle.js:1)
at bundle.js:1
at Object.14../copy (bundle.js:803)

Salesforce LWC Uncaught (in promise) TypeError: Cannot read property 'Symbol(ViewModel)' of undefined

I am getting this error when running a Salesforce scratch org application;
aura_proddebug.js:274 Uncaught (in promise) TypeError: Cannot read property 'Symbol(ViewModel)' of undefined
at getInternalField (aura_proddebug.js:274)
at Object.update (aura_proddebug.js:1793)
at updateCustomElmDefaultHook (aura_proddebug.js:5627)
at Object.update (aura_proddebug.js:5779)
at patchVnode (aura_proddebug.js:5021)
at updateStaticChildren (aura_proddebug.js:5000)
at aura_proddebug.js:5542
at runWithBoundaryProtection (aura_proddebug.js:8255)
at updateChildrenHook (aura_proddebug.js:5541)
at Object.update (aura_proddebug.js:5751)
Has anyone experienced this before?
I was actually able to spot the issue.
This error has been thrown before in my org when I either didn't have the .html file or I had it with an improper spelling somehow; include case sensitivity on the names.
See related here:

cannot see a variable from Chrome Console but it's accessible in code

Why is a variable accessible from inside a method but not from the browser console?
I have the following typescript code, using angular6, run via ng serve on Windows 10, current Chrome.
import * as d3 from "d3"; // from "npm i d3 --save" version 5.7
// picking a member of d3, nothing magical about "scaleLinear" here
console.log("see", d3.scaleLinear) // it prints ok, ƒ linear() {...
// angular component code fragment below
somefunction() {
console.log("see again", d3.scaleLinear) // it prints ok, again
// add a break here
}
I drive the code to that somefunction. At break, in Chrome console when I try:
> console.log(d3.scaleLinear)
it throws an error:
VM2012:1 Uncaught ReferenceError: d3 is not defined
at eval (eval at push../src/app/user-sel/user-sel.component.ts.UserSelComponent._resyncYSel (user-sel.component.ts:58), <anonymous>:1:13)
at UserSelComponent.push../src/app/user-sel/user-sel.component.ts.UserSelComponent._resyncYSel (user-sel.component.ts:58)
at UserSelComponent.push../src/app/user-sel/user-sel.component.ts.UserSelComponent.selYSel (user-sel.component.ts:166)
at Object.eval [as handleEvent] (UserSelComponent.html:75)
at handleEvent (core.js:21673)
at callWithDebugContext (core.js:22767)
at Object.debugHandleEvent [as handleEvent] (core.js:22470)
at dispatchEvent (core.js:19122)
at core.js:19569
at HTMLSpanElement.<anonymous> (platform-browser.js:993)
How can I access d3 in console directly? What did I miss? I looked at old SO questions on this topic 52332640 but could not find a conclusive answer.
If your pages have any frames, your console could be running in the wrong context.
There is a dropdown that will allow you to specify the correct context
For example, in this screenshot, there are two IFrame elements. In order to access variables from scripts running in "contentIframe2" I have to switch the context

How to get the stacktrace of an error when using rxjs?

I'm using angular-cli to build a small angular2 web app and I'm debugging with chrome dev-tools.
Clearly I'm doing something wrong if I need to guess each time where is the source of the error and what is the stack-trace of that error.
Take for example this error:
error_handler.js:45EXCEPTION: Cannot read property 'provider' of nullErrorHandler.handleError # error_handler.js:45
error_handler.js:50ORIGINAL STACKTRACE:ErrorHandler.handleError # error_handler.js:50
error_handler.js:51TypeError: Cannot read property 'provider' of null
at MapSubscriber.project (auth.effects.ts:80)
at MapSubscriber._next (map.js:77)
at MapSubscriber.Subscriber.next (Subscriber.js:89)
at DistinctUntilChangedSubscriber._next (distinctUntilChanged.js:72)
at DistinctUntilChangedSubscriber.Subscriber.next (Subscriber.js:89)
at MapSubscriber._next (map.js:83)
at MapSubscriber.Subscriber.next (Subscriber.js:89)
at MapSubscriber._next (map.js:83)
at MapSubscriber.Subscriber.next (Subscriber.js:89)
at RefCountSubscriber.Subscriber._next (Subscriber.js:125)ErrorHandler.handleError # error_handler.js:51
zone.js:355Unhandled Promise rejection: Cannot read property 'provider' of null ; Zone: <root> ; Task: Promise.then ; Value: TypeError: Cannot read property 'provider' of null(…) TypeError: Cannot read property 'provider' of null
at MapSubscriber.project (http://localhost:4200/main.bundle.js:35342:83)
at MapSubscriber._next (http://localhost:4200/main.bundle.js:4171:35)
at MapSubscriber.Subscriber.next (http://localhost:4200/main.bundle.js:395:18)
at DistinctUntilChangedSubscriber._next (http://localhost:4200/main.bundle.js:25485:30)
at DistinctUntilChangedSubscriber.Subscriber.next (http://localhost:4200/main.bundle.js:395:18)
at MapSubscriber._next (http://localhost:4200/main.bundle.js:4177:26)
at MapSubscriber.Subscriber.next (http://localhost:4200/main.bundle.js:395:18)
at MapSubscriber._next (http://localhost:4200/main.bundle.js:4177:26)
at MapSubscriber.Subscriber.next (http://localhost:4200/main.bundle.js:395:18)
at RefCountSubscriber.Subscriber._next (http://localhost:4200/main.bundle.js:431:26)consoleError # zone.js:355
zone.js:357Error: Uncaught (in promise): TypeError: Cannot read property 'provider' of null
at resolvePromise (http://localhost:4200/main.bundle.js:93214:31)
at http://localhost:4200/main.bundle.js:93191:13
at ZoneDelegate.invoke (http://localhost:4200/main.bundle.js:92988:28)
at Zone.run (http://localhost:4200/main.bundle.js:92881:43)
at http://localhost:4200/main.bundle.js:93247:57
at ZoneDelegate.invokeTask (http://localhost:4200/main.bundle.js:93021:37)
at Zone.runTask (http://localhost:4200/main.bundle.js:92921:47)
at drainMicroTaskQueue (http://localhost:4200/main.bundle.js:93153:35)consoleError # zone.js:357
The problem:
This errors means nothing to me. It's completely uselss and un readble.
I got lucky that I saw this line (sometimes I dont get any indication where the error is): at MapSubscriber.project (auth.effects.ts:80) - This line is the only line that usefull here to get some idea how to fix that bug.
Trying to understand the stack-trace will be pointless because its all rxjs stack-trace.
My question:
I would like to know my code's stack-trace. Is that possible?
where in my code the subscription to that observable happens.
If its an observable from ngrx, then where in my code someone dispanched that action that causes the error.
Its more general question about how to debug async code with rxjs then fixing this specific bug.
It happened in the projection method you provided to a map operator. The clue is at the top of your stack. MapSubscriber.project.
Basically you read stack traces from the top. The top most call is where the error was thrown (or rethrown).
In RxJS 5, there are usually two or three calls per operator. Each operator has a subscriber named after it that does the work. MapSubscriber.Subscriber.next MapSubscriber._next etc

Categories