Javascript infinite loop when applying shader to material


I have written a custom shader and am trying to apply a it to a material, but when I try to run the app, the scene partially loads and there is a Javascript error in the browser console, specifically:

playcanvas-stable.js:4782 Uncaught TypeError: Cannot read property 'ready' of undefined playcanvas-stable.js:4539 Uncaught TypeError: Cannot read property 'samplers' of undefined'

this is my shader code

pc.script.attribute('vs', 'asset'); pc.script.attribute('fs', 'asset'); pc.script.attribute('diffuseMap', 'asset');

pc.script.attribute('tint', 'rgba', [1,1,1,1]); pc.script.create('customShader', function (app) { // Creates a new CustomShader instance var CustomShader = function (entity) { this.entity = entity; };

CustomShader.prototype = {
    // Called once after all resources are loaded and before the first update
    initialize: function () {
    initializeShader: function() {
        //var app =;
        var model = this.entity.model.model;
        var gd = app.graphicsDevice;
        var diffuseTexture = this.diffuseMap;
        var vertexShader = this.vs;
        var fragmentShader = this.fs;
        var shaderDefinition = {
           attributes: {
                aPositon: pc.SEMANTIC_POSTION,
                aUv0: pc.SEMANTIC_TEXCOORD0
            vshader: vertexShader,
            fshader: fragmentShader
        this.shader = new pc.Shader(gd, shaderDefinition);
        this.material = new pc.Material();
        this.material.setParameter('uDiffuseMap', diffuseTexture);
        model.meshInstances[0].material = this.material;

    update: function (dt) {

return CustomShader;


There is a typo here should be this.shader

Cheers, but that seems to have changed the error to:

playcanvas-stable.js:3601 Uncaught TypeError: src.split is not a function playcanvas-stable.js:4548 Uncaught TypeError: Cannot read property 'length' of undefined

Thank you so far though.