Skip to content

Conversation

@Karthikeya1500
Copy link

Related issue: None

Description

This PR adds a missing error check inside FunctionNode.getNodeFunction().
When builder.parser.parseFunction() fails to parse the WGSL/GLSL shader
function, it returns undefined. This leads to unclear runtime errors later
in the node-building pipeline (e.g., accessing .inputs, .type, .name on
an undefined object).

By validating the parser result immediately and throwing a clear error
message, developers receive instant feedback about invalid shader code, making
TSL debugging significantly easier.

What this PR changes

  • Adds a guard check after parsing a function:
    if ( ! nodeFunction ) {
        throw new Error(
            'TSL: Failed to parse function in FunctionNode. Check the shader syntax:\n' + this.code
        );
    }

@github-actions
Copy link

📦 Bundle size

Full ESM build, minified and gzipped.

Before After Diff
WebGL 356.24
86.48
356.24
86.48
+0 B
+0 B
WebGPU 615.97
172.86
616.13
172.91
+160 B
+51 B
WebGPU Nodes 614.57
172.61
614.73
172.66
+160 B
+51 B

🌳 Bundle size after tree-shaking

Minimal build including a renderer, camera, empty scene, and dependencies.

Before After Diff
WebGL 488.12
121.26
488.12
121.26
+0 B
+0 B
WebGPU 688.33
188.85
688.49
188.91
+160 B
+60 B
WebGPU Nodes 630.05
172.08
630.21
172.13
+160 B
+56 B

@Karthikeya1500

This comment was marked as spam.

@mrdoob mrdoob closed this Nov 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants