Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SDKError: Ti is not defined #289

Open
vinitdeshkar opened this issue Sep 20, 2022 · 3 comments
Open

SDKError: Ti is not defined #289

vinitdeshkar opened this issue Sep 20, 2022 · 3 comments

Comments

@vinitdeshkar
Copy link

vinitdeshkar commented Sep 20, 2022

Background:
When we started using pubnub (v 4.37.x), we started getting could not load bridge.js error.
Issue is described here which is still open #266

bridge.js belongs to vm2, it's used by pubnub -> degenerator -> vm2.
webpack couldn't handle contents of vm2 (bridge.js).

In order to fix this issue, we used pubnub.min.js from pubnub/dist/titanium/pubnub.min.js

Below was the fix added in webpack config:

resolve: {
      extensions: ['.tsx', '.ts', '.js'],
      alias: {
        pubnub: path.resolve(appModulesDir, 'pubnub', 'dist', 'titanium', 'pubnub.min.js')
      }
},

This temporary fix worked for sometime.
But now we are getting different error "SDKError: Ti is not defined" on below line -

https://github.com/pubnub/javascript/blob/master/lib/networking/modules/titanium.js#L27

Can someone please suggest what might be causing this problem?

Environment Details:
Node v14.18.3
NPM v6.14.15
Webpack v4.46.0

@jazpearson
Copy link

I added the files to my webpack config, so at least the files are bundled. Ideally we wouldn't need to do this, but at least it works.

// these files are required by vm2 which is a dependency of the pubnub SDK
const bridgeConfig = {
  entry: './node_modules/vm2/lib/bridge.js',
  output: {
      filename: 'bridge.js',
      path: path.resolve(__dirname, '../build')
  }
};
const sandboxConfig = {
  entry: './node_modules/vm2/lib/setup-sandbox.js',
  output: {
      filename: 'setup-sandbox.js',
      path: path.resolve(__dirname, '../build')
  }
};


module.exports = [
    ...otherConfigs,
    bridgeConfig,
    sandboxConfig
]

@vinitdeshkar
Copy link
Author

vinitdeshkar commented Sep 26, 2022

Tried this workaround but now I am getting below warning-

(node:73234) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead. (Use node --trace-deprecation ... to show where the warning was created)

@vinitdeshkar
Copy link
Author

Thanks @jazpearson for suggesting a workaround.

We copied files bridge.js and setup-sandobox.js and also switched to node package bundle of pubnub.

resolve: {
      extensions: ['.tsx', '.ts', '.js'],
      alias: {
        pubnub: path.resolve(appModulesDir, 'pubnub', 'lib', 'node', 'index.js')
      }
}

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

No branches or pull requests

2 participants