title: Cypress TypeError: Cannot read properties of undefined (reading 'uid')
body: <p>I have a Cypress project with TypeScript support using the Cucumber Preprocessor and all of a sudden it started to throw the below exception:</p>
  <pre><code> TypeError: Cannot read properties of undefined (reading 'uid')
  </code></pre>
  <p>Some times it works when I change to a different workspace but again this error is reproducing when I open the Cypress runner itself and even when executing in Jenkins too.</p>
  <p><strong>Cypress Runner:</strong> (v8.4.0)</p>
  <p><a href="https://i.stack.imgur.com/D0GuT.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/D0GuT.png" alt="Cypress Runner" /></a></p>
  <p><strong>Jenkins Console:</strong> (v8.7.0)</p>
  <pre><code>The function exported by the plugins file threw an error.
  
  We invoked the function exported by `C:\Jenkins\workspace\ABC\cypress\plugins\index.js`, but it threw an error.
  
   TypeError: Cannot read properties of undefined (reading 'uid')
      at Object.statSync (C:\Windows\SysWOW64\config\systemprofile\AppData\Local\Cypress\Cache\8.7.0\Cypress\resources\app\packages\server\node_modules\graceful-fs\polyfills.js:303:17)
      at isDirectory (C:\Jenkins\workspace\ABC\ui\node_modules\resolve\lib\sync.js:22:23)
      at loadNodeModulesSync (C:\Jenkins\workspace\ABC\ui\node_modules\resolve\lib\sync.js:191:17)
      at Function.resolveSync [as sync] (C:\Jenkins\workspace\ABC\ui\node_modules\resolve\lib\sync.js:98:17)
      at module.exports (C:\Jenkins\workspace\ABC\ui\cypress\plugins\index.js:15:25)
      at C:\Windows\SysWOW64\config\systemprofile\AppData\Local\Cypress\Cache\8.7.0\Cypress\resources\app\packages\server\lib\plugins\child\run_plugins.js:90:12
      at tryCatcher (C:\Windows\SysWOW64\config\systemprofile\AppData\Local\Cypress\Cache\8.7.0\Cypress\resources\app\packages\server\node_modules\bluebird\js\release\util.js:16:23)
      at Function.Promise.attempt.Promise.try (C:\Windows\SysWOW64\config\systemprofile\AppData\Local\Cypress\Cache\8.7.0\Cypress\resources\app\packages\server\node_modules\bluebird\js\release\method.js:39:29)
      at load (C:\Windows\SysWOW64\config\systemprofile\AppData\Local\Cypress\Cache\8.7.0\Cypress\resources\app\packages\server\lib\plugins\child\run_plugins.js:87:7)
      at EventEmitter.&lt;anonymous&gt; (C:\Windows\SysWOW64\config\systemprofile\AppData\Local\Cypress\Cache\8.7.0\Cypress\resources\app\packages\server\lib\plugins\child\run_plugins.js:198:5)
      at EventEmitter.emit (events.js:376:20)
      at process.&lt;anonymous&gt; (C:\Windows\SysWOW64\config\systemprofile\AppData\Local\Cypress\Cache\8.7.0\Cypress\resources\app\packages\server\lib\plugins\util.js:19:22)
      at process.emit (events.js:376:20)
      at process.emit (C:\Windows\SysWOW64\config\systemprofile\AppData\Local\Cypress\Cache\8.7.0\Cypress\resources\app\packages\server\node_modules\source-map-support\source-map-support.js:495:21)
      at emit (internal/child_process.js:910:12)
      at processTicksAndRejections (internal/process/task_queues.js:83:21)
  error Command failed with exit code 1.
  </code></pre>
  <p><strong>plugins/index.js</strong></p>
  <pre><code>const resolve = require('resolve');
  const cucumber = require(&quot;cypress-cucumber-preprocessor&quot;).default;
  const cypressBrowserify = require(&quot;@cypress/browserify-preprocessor&quot;);
  const mysql = require('mysql2')
  const db = require('../../cypress.json')
  var mssql = require('mssql');
  const path = require('path');
  const fs = require('fs-extra');
  const allureWriter = require('@shelex/cypress-allure-plugin/writer');
  
  module.exports = (on, config) =&gt; {
    
    const options = {
      ...cypressBrowserify.defaultOptions,
      typescript: resolve.sync('typescript', {project:  config.projectRoot}),
    };  
    
    on(&quot;file:preprocessor&quot;, cucumber(options));
  
    on('task', {
      'createMySQLConnection'(query) {
        var value = mysqlDB(query)
        return value
      }
    });
  
    function mysqlDB(query) {
      var dbenv = config.env.configFile
      var connection=&quot;&quot;;
      if(dbenv==&quot;qa&quot;){
        connection = mysql.createConnection(db.qa)
      }
      else if(dbenv==&quot;stg&quot;){
        connection = mysql.createConnection(db.stg)
      }
      else if(dbenv==&quot;stg2&quot;){
        connection = mysql.createConnection(db.stg2)
      }
      connection.connect()
      return new Promise((resolve, reject) =&gt; {
        connection.query(query, (error, results) =&gt; {
          if (error) {
            return reject(error)
          }
          connection.end()
          return resolve(results)
    
        })
      })
    }
  
    on('task', {
      'createMSSQLConnection'(query) {
        return mssqlDB(query)
      }
    });
  
  
   async function mssqlDB(query){
     const connection = await mssql.connect(db.env);
     var sqlServerRequest = new mssql.Request(connection);
     return new Promise((resolve, reject) =&gt; {
      sqlServerRequest.query(query, (error, recordset) =&gt; {
        mssql.close(); 
        if(error){
        reject (error)
        }
        else{
          resolve (recordset)
        }
      }) 
    })
   };
   
    allureWriter(on, config);
    const file = config.env.configFile || 'stg2';
    const pathToConfigFile = path.resolve('cypress/config', `${file}.json`);
    return config,fs.readJson(pathToConfigFile);
    
  }
  </code></pre>
  <p><strong>support/index.ts</strong></p>
  <pre><code>import './commands';
  import '@shelex/cypress-allure-plugin/reporter';
  import 'cypress-xpath';
  import 'cypress-plugin-tab';   
  
  Cypress.on('uncaught:exception', (err, runnable) =&gt; {
    cy.log(`Uncaught Exception: ${JSON.stringify(err)}`);
  
    return false;
  });
  </code></pre>