Macro issue in React4XP

Enonic version: 7.14.4
OS: Linux

Hi,

I’m posting this as a bug as we were not able, so far, to identify where the problem’s origin. We have a macro to display code blocks and it seems it has a random behavior, sometimes it works and sometimes it doesn’t. We weren’t able to reproduce it aside from luck.

This is the top of the stacktrace:

17:47:31.297 ERROR c.e.l.react4xp.ssr.renderer.Renderer - org.graalvm.polyglot.PolyglotException: TypeError: Cannot read property 'A' of undefined
TypeError: Cannot read property 'A' of undefined
	at <js> :anonymous(<eval>:1:336-338)
	at <js> l(<eval>:1:290-388)
	at org.graalvm.truffle/com.oracle.truffle.polyglot.PolyglotMapAndFunction.apply(PolyglotMapAndFunction.java:46)
	at com.enonic.lib.react4xp.ssr.renderer.Renderer.render(Renderer.java:122)
	at com.enonic.lib.react4xp.ssr.ServerSideRenderer.render(ServerSideRenderer.java:101)
	at org.openjdk.nashorn.internal.scripts.Script$Recompilation$13972$6324AAA$index.L:1#render$1(no.seeds.99x:/lib/enonic/react4xp/index.js:160)
	at org.openjdk.nashorn.internal.scripts.Script$Recompilation$13960$6448A$index.L:1#doRenderSSR(no.seeds.99x:/lib/enonic/react4xp/index.js:166)
	at org.openjdk.nashorn.internal.scripts.Script$Recompilation$13959$17767A$index.L:1#renderSSRIntoContainer(no.seeds.99x:/lib/enonic/react4xp/index.js:408)
	at org.openjdk.nashorn.internal.scripts.Script$Recompilation$13956$7961A$index.L:1#renderBody(no.seeds.99x:/lib/enonic/react4xp/index.js:201)
	at org.openjdk.nashorn.internal.scripts.Script$Recompilation$14528$6674A$codeBlock.L:1#getBody#codeBlock(no.seeds.99x:/site/macros/codeBlock/codeBlock.js:171)
	at org.openjdk.nashorn.internal.scripts.Script$Recompilation$14522$5157AAA$codeBlock.L:1#getBody(no.seeds.99x:/site/macros/codeBlock/codeBlock.js:166)
	at org.openjdk.nashorn.internal.scripts.Script$Recompilation$14515$4112A$codeBlock.L:1#macro-1(no.seeds.99x:/site/macros/codeBlock/codeBlock.js:125)
	at org.openjdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:648)
	at org.openjdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:513)
	at org.openjdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:520)
	at org.openjdk.nashorn.api.scripting.ScriptObjectMirror.call(ScriptObjectMirror.java:111)

This is what we see when the problem shows up:

Any ideas what could cause this?

Hi @maaubt !

What versions of react4xp and xp itself do you use ?

I have looked through the sources assuming you’re on react4xp v5.1.1 and it looks like it’s the invocation of your entry file that gives the error.

It’s hard to tell what’s the cause here, but I recommend checking 3 things:

  • codeBlock entry should export a default function
  • pay extra attention that function doesn’t throw unhandled exception during execution
  • also verify parameters that you pass to the render function

Good luck :crossed_fingers:

1 Like

Hi,
It’s indeed 5.1.1.
I’ll make sure to check those asap. If that doesn’t help I can post the piece that’s throwing the exception afterwards.