-
Notifications
You must be signed in to change notification settings - Fork 3
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
RN + SES: TypeError: undefined is not a function (near '...globalThis.process.on...') #11
Comments
NB: Not an issue with [email protected] investigation in the past Since we don't have RN projects on older versions of SES (nor using SES at all!), supporting SES backward-compatibility for RN isn't feasible, unless latest SES version(s) prove to be a blocker in due course |
rn-nodeify appears to be a worthwhile candidate/hack to introduce our nb: consider saner approach https://github.com/philikon/ReactNativify |
Solution:
// index.js
import './shim'; // added
import 'ses'; // added
import {AppRegistry} from 'react-native';
import App from './App';
import {name as appName} from './app.json';
lockdown({consoleTaming: 'unsafe'}); // added
AppRegistry.registerComponent(appName, () => App);
Error: Unable to resolve module buffer from /Users/leo/Documents/GitHub/RN665/shim.js: buffer could not be found within the project or in these directories:
node_modules
../../../node_modules We don't need the the Node buffer API, so we can skip it in our generated shim for now (TODO: attenuate further) if (typeof __dirname === 'undefined') global.__dirname = '/'
if (typeof __filename === 'undefined') global.__filename = ''
if (typeof process === 'undefined') {
global.process = require('process')
} else {
const bProcess = require('process')
for (var p in bProcess) {
if (!(p in process)) {
process[p] = bProcess[p]
}
}
}
process.browser = false
// if (typeof Buffer === 'undefined') global.Buffer = require('buffer').Buffer // commented
// global.location = global.location || { port: 80 }
const isDev = typeof __DEV__ === 'boolean' && __DEV__
process.env['NODE_ENV'] = isDev ? 'development' : 'production'
if (typeof localStorage !== 'undefined') {
localStorage.debug = isDev ? '*' : ''
}
// If using the crypto shim, uncomment the following line to ensure
// crypto is loaded first, so it can populate global.crypto
// require('crypto')
We now have ourselves a functional RN 0.66.5 app (full) with Promise warnings only to look into next, but no errors as seen previously with [email protected] WARN Removing intrinsics.Promise._B
WARN Removing intrinsics.Promise._C
WARN Removing intrinsics.Promise._D
WARN Removing intrinsics.Promise.resolve.prototype
WARN Tolerating undeletable intrinsics.Promise.resolve.prototype === undefined
WARN Removing intrinsics.Promise.all.prototype
WARN Tolerating undeletable intrinsics.Promise.all.prototype === undefined
WARN Removing intrinsics.Promise.allSettled.prototype
WARN Tolerating undeletable intrinsics.Promise.allSettled.prototype === undefined
WARN Removing intrinsics.Promise.reject.prototype
WARN Tolerating undeletable intrinsics.Promise.reject.prototype === undefined
WARN Removing intrinsics.Promise.race.prototype
WARN Tolerating undeletable intrinsics.Promise.race.prototype === undefined
WARN Removing intrinsics.%PromisePrototype%.then.prototype
WARN Tolerating undeletable intrinsics.%PromisePrototype%.then.prototype === undefined
WARN Removing intrinsics.%PromisePrototype%.done
WARN Removing intrinsics.%PromisePrototype%.finally.prototype
WARN Tolerating undeletable intrinsics.%PromisePrototype%.finally.prototype === undefined
WARN Removing intrinsics.%PromisePrototype%.catch.prototype
WARN Tolerating undeletable intrinsics.%PromisePrototype%.catch.prototype === undefined |
we don't want to shim with SES (unless edit: vetted shim discussion next endo meeting 12th July 2023 |
Follow-up to
npx [email protected] init RN0665 --version 0.66.5
yarn add ses
yarn start --reset-cache
yarn start ios
Result:
ERROR TypeError: undefined is not a function (near '...globalThis.process.on...')
(this|global|globalThis|window).process
in our RN realm contains only{"env": {"NODE_ENV": "development"}}
global
,self
as aliases forglobalThis
LavaMoat#459So our Node API methods (on/exit/abort/etc) are missing https://nodejs.org/api/process.html#process (being an instance of
EventEmitter
)Which we now need to be added to our vanilla RN PoC
First seen in
The text was updated successfully, but these errors were encountered: