-
Notifications
You must be signed in to change notification settings - Fork 374
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
ReferenceError: Can't find variable: Buffer --> pusher-js 7.5.0 not working with react-native #654
Comments
@oelerpearler same here. The error you're describing has to do with the After some digging I found two ways to move forward:
However, when I switched to this new lib, I've run into another issue, which may not apply for other projects, but it was blocking in my situation because I am using another conflicting libs that in my app. So, my only way forward now was to use my own fork of the official pusher for react-native, which so far works OK-ish, but is not very pleasant to use with authentication. I'm really starting to re-consider our choice for Pusher for our project, at this point :-/ |
It's worth noting that downgrading to With import Echo from "laravel-echo";
import Pusher from "pusher-js/react-native";
Pusher.logToConsole = true;
const client = new Pusher("<PUSHER_KEY>", {
cluster: "mt1",
wsHost: "localhost",
wsPort: 6001,
enabledTransports: ["ws"],
forceTLS: false,
});
const echo = new Echo({
broadcaster: "pusher",
client,
disableStats: true,
}); |
Still facing the issue can't find variable: Buffer |
I can confirm that downgrading to v7.4.0 works in my app, and without any shims from rn-nodeify. Thanks @eightyfive for the tip! An observation: it has to be exactly version It looks like something changed in the internal tooling to build the dist files, because starting with v7.4.1, there's a separate codeblock in the resulted file @akhzarna , make sure you set the exact version
Make sure there's no |
Can confirm that locking to 7.4.0 solves this issue. Make sure you use |
My team and I faced this issue a month ago and we couldn't find a solution until the app displays the stack trace and we saw "pusher.js" in the logs. Man, I hope they could fix this issue ASAP. |
There is another way: https://github.com/craftzdog/react-native-buffer It's a JSI polyfill and fast. I did not test it but it might work. |
work for me in react-native |
@chanphiromsok Could you please update to the newest version? |
Although it has been already mentionned as a comment (#645 (comment)) in another issue #645, I thought it would be better to create a new issue, since the initial issue description in #645 is mentioning another error, so it might also have different root causes.
Long story short: If you update in a react-native project to the latest pusher-js versions 7.4.1 or 7.5.0, the build phase will work, but when the app tries to start, it will crash and you receive an error
The project in which I use pusher is on React Native 0.67.4, but the comment from hirbod in #645 (comment) indicates a potential newer version of react native also being affected. Either way I think it doesn't depend much on the react-native version, just pusher-js tryng to use the Buffer type which is (as far as I know) only available in a node-js runtime (also mentionned by hirbod in #645 (comment) suggesting that maybe a polyfill is missing or not working correctly)
The text was updated successfully, but these errors were encountered: