Closed henrikekblad closed 6 years ago
What version of Benchpress? npm ls benchpressjs
Can you upload node_modules/benchpressjs/build/lib/runtime.js
to a Gist or something? It should have a polyfill for Promise.try
1.2.0 The runtime.js actually contains a polyfill for Promise.try(). Weird indeed.
If you could devise a piece of code to reproduce this consistently, I would happily fix it. If you can't do that, provide me with as much information as you can. That means code, template sources, NodeBB version, try inserting console logs around.
BTW, if your use of compileRender
/ compileParse
is unavoidable (especially if the input template changes), I would suggest you use JS template literals instead of Benchpress. It isn't made for on-the-fly renders.
Thanks, I will happily send you the full plugin over email. It must be some breaking change between 1.4.4 -> 1.6.1 or some incompatibility with the node version.
It'll arrive in a few minutes.
Ok so I figured out the issue. It's caused by the (outdated, btw) amazon-product-api
module using the es6-promise
library which overrides the global Promise object, destroying my Promise.try
polyfill.
I updated the module to the latest version (v0.4.4) and that seemed to fix the issue. I'm not sure if it is compatible with the old API, though. You might try that, or at least updating your own fork to not use the overriding polyfill.
BTW, the idiomatic way to access NodeBB APIs now is to use require.main.require
instead of module.parent.require
. Also, you should NOT be requiring modules that way unless they are internal NodeBB modules or if they are nconf
, winston
, or maybe benchpressjs
if your plugin needs to register helpers. You should have string
and async
in your package.json, and require them locally instead of through require.main or module.parent.
I've uploaded the changes I made to your plugin and will send you an email with the changes I made.
Wow, thank you! Doh! Been starring at it for hours. I never thought of the possibility of amazon-product-api could interfere.
Will test everything when I'm back home from work tonight.
Works!
Converting some old NodeBB plugins (that was running on 1.4.4).
I'm getting the following error:
Using nodejs version v8.9.1
Any help on what the problem could be would be very appreciated.