firebase functions get error stream removed onCreate firestore event - javascript

I'm worried about this error on firebase functions,
I have a sendgrid dispatch on this function:
exports.mailDealings = functions.firestore
.document('dealings/current').onCreate(event => {
// send mail
const msg = {...}
sgMail.send(msg);
})
.catch(result => {
console.error("sendgrid error", result);
});
I was able to execute with success before but on one call,
this function give me the error below:
{ Error: Stream removed
at ClientReadableStream._emitStatusIfDone (/user_code/node_modules/firebase-admin/node_modules/grpc/src/client.js:255:19)
at ClientReadableStream._receiveStatus (/user_code/node_modules/firebase-admin/node_modules/grpc/src/client.js:233:8)
at /user_code/node_modules/firebase-admin/node_modules/grpc/src/client.js:705:12 code: 2, metadata: Metadata { _internal_repr: {} } }
There should have an automatic retry for this error, right?
Or at least a method for turning this easy, like result.retry(1000)?

Same problem here (in many functions & randomly) since 3 / 4 days.
Apparently t disappears after deploy...for few minutes
Error: Stream removed
at ClientReadableStream._emitStatusIfDone (/user_code/node_modules/firebase-admin/node_modules/grpc/src/client.js:255:19)
at ClientReadableStream._receiveStatus (/user_code/node_modules/firebase-admin/node_modules/grpc/src/client.js:233:8)
at /user_code/node_modules/firebase-admin/node_modules/grpc/src/client.js:705:12

From the Google Groups discussion on this bug:
Hello all, Sebastian from the Firestore SDK team here. We believe this
issue is related to the recent update of the GRPC Client SDK and have
been running tests with GRPC 1.7.1. So far, we have not been able to
reproduce this issue with this older GRPC version.
#google-cloud/firestore is now at 0.10.1. If you update your
dependencies, you will be able to pull in this release.
Thanks for your patience.
Sebastian
This seems to have fixed the issue for me!

Related

Resource not found when attempting to send voice message through AWS Pinpoint

I currently have a Node.js service to send a voice call through AWS Pinpoint. However, I'm getting a Resource not found response after making a call. I tested with PinpointSMSVoice.sendVoiceMessage which succeeds in making the call. The one that doesn't work is Pinpoint.sendMessages. My request object looks like this:
{
ApplicationId: 'project-id',
MessageRequest: {
Addresses: {
['destination-number']: {
ChannelType: 'VOICE',
Substitutions: {
// Using a template
}
}
},
MessageConfiguration: {
VoiceMessage: {
LanguageCode: 'en-US',
OriginationNumber: 'origination-number'
}
},
TemplateConfiguration: {
VoiceTemplate: {
Name: 'voice-template
}
}
}
};
pinpoint.sendMessages(requestObj, callback);
I should note that I am not in sandbox mode, it was approved and moved to production mode. I have tested the same setup with SMS which works perfectly well. I'm not quite sure what the difference is between PinpointSMSVoice.sendVoiceMessage and Pinpoint.sendMessages, except for the fact that Pinpoint.sendMessages allows me to set a template. Any ideas on what else I could be missing?
I'm encountering the same issue. It works using PinPointSMSVoice client, but that won't let me use a template. I've also tested this using V3 of the AWS JS SDK, which modularizes the clients #aws-sdk/client-pinpoint-sms-voice and #aws-sdk/client-pinpoint, but the behaviour is the same. It works uses the same tempplate in the 'Test Message' feature in the console, so seems to be a JS SDK issue. I suggest you raise the issue with JS SDK team https://github.com/aws/aws-sdk-js-v3
When you use PinPoint to perform the sendVoiceMessage operation, you need to set the content type to application/json. If you do not, you get this exception. To see an example (this is the AWS Java API), see this Github URL:
https://github.com/awsdocs/aws-doc-sdk-examples/blob/master/javav2/example_code/pinpoint/src/main/java/com/example/pinpoint/SendVoiceMessage.java

The provided value 'moz-chunked-arraybuffer' is not a valid 'responseType

first time position a question here.
I am building an app with react native and expo and I have implemented an audio player that plays from an Icecast stream.
What I'm trying to achieve now is to get the metadata from the icecast stream so I have installed this library: https://github.com/ghaiklor/icecast-parser.
However, since it uses the http, events and stream modules form node I installed the following package to get them in react native: https://github.com/parshap/node-libs-react-native/, which managed to get the parsing library to work.
Now, the issue I'm having is that after the icecast-parser makes the http request for the stream, I get the following errors:
"The provided value 'moz-chunked-arraybuffer' is not a valid 'responseType'."
"The provided value 'ms-stream' is not a valid 'responseType'."
After reading https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequestResponseType I think the issue is that for some reason the response coming from the request is of that type which is what gives me the error.
So I'm trying to find if there's a way to transform it or make it work and was wondering if you had an idea or could point me in the right direction?
Here's the part of the code where the error occurs:
_makeRequest () {
const request = (this.getConfig('url').indexOf('https://') === 0) ?
https.request(this.getConfig('url')) : http.request(this.getConfig('url'));
request.setHeader('Icy-MetaData', '1');
request.setHeader('User-Agent', this.getConfig('userAgent'));
request.once('socket', function (socket) {
socket.once('end', this._onSocketEnd.bind(this));
}.bind(this));
console.log("I get here")
request.once('response', this._onRequestResponse.bind(this));
console.log("I don't get here")
request.once('error', this._onRequestError.bind(this));
request.end();
return this;
}
_onRequestResponse (response) {
console.log("not getting here")
const icyMetaInt = response.headers['icy-metaint'];
if (icyMetaInt) {
const reader = new StreamReader(icyMetaInt);
reader.on('metadata', metadata => {
this._destroyResponse(response);
this._queueNextRequest(this.getConfig('metadataInterval'));
this.emit('metadata', metadata);
});
response.pipe(reader);
this.emit('stream', reader);
} else {
this._destroyResponse(response);
this._queueNextRequest(this.getConfig('emptyInterval'));
this.emit('empty');
}
return this;
}
Apparently the issue comes from the fact that the library is built for nodeJS so even if I add a package that imports the required libraries into react-native, the code won't work. Tested this with a different parsing library that was built for nodeJS too.
try suppressing the warning using this line of code
LogBox.ignoreLogs
(['Warning: The provided value \'moz',
'Warning: The provided value \'ms-stream'
])

Facebook SDK & custom button Login in react-native 0.60+ not working

i'm trying to implement Facebook login in my React-Native app but for some reason, it's throwing Cannot read property 'logInWithPermissions' of undefined.
I'm using React-Native 0.60.4.
I've downloaded FacebookSDK 5.3.0 (_Stable framework)
Attempted using Cocoapod but after some research, many people don't suggest using it because it messes up the project.
These are the steps I followed:
Downloaded FacebookSDK 5.3.0 (current latest up to 08/15/19)
Dropped the FBSDKCoreKit.framework, FBSDKLoginKit.framework and FBSDKShareKit.framework inside a folder as ~/Documents/FacebookSDK.
Also dropped those 3 framework files inside my project in XCode in the /Frameworks folder.
Just in case, I also added the path ~/Documents/FacebookSDK in the Framework Search Paths under Build Settings.
Made a Build on XCode, it's successful.
I download react-native-fbsdk from my react-native project. It downloads version 1.0.1.
I don't add libRTCFBSDK.a file in the Link binary with Libraries because it throws an error saying the FBSDKShareKit.h isn't found.
This is what I do on my AuthView.js, I add this to a simple bound onPress event in a TouchableOpacity.
const FBSDK = require('react-native-fbsdk');
const {
LoginManager,
} = FBSDK;
handleFacebookLogin() {
LoginManager.logInWithPermissions(['public_profile', 'publish_actions']).then(
(result) => {
if (result.isCancelled) {
console.log('Login cancelled')
} else {
console.log('Login success with permissions: ' + result.grantedPermissions.toString())
}
},
(error) => {
console.log('Login fail with error: ' + error)
}
)
}
Now, I notice that inside Facebook's FBLoginManager.js this is the function being called
logInWithPermissions(permissions: Array<string>): Promise<LoginResult> {
return LoginManager.logInWithPermissions(permissions);
},
Whenever I hover LoginManager, it says it's undefined. Why would this be undefined? When it's literally a const on top of the file
const LoginManager = require('react-native').NativeModules.FBLoginManager;
Can anyone help me? I've been struggling for 4 days now. I already attempted installing it with cocoapods, no success. Then doing react-native link react-native-fbsdk no success... a lot of people suggested NOT using link but doing it manually.
What else could I try? Thanks.
You must add libRTCFBSDK.a file in the Link binary with Libraries . To fix the 'FBSDKShareKit.h isn't found' issue change ~/Documents/FacebookSDK to $(HOME)/Documents/FacebookSDK

Jimp.read creating error - zlib binding closed

I am working using Node and Discord.js, making edits to the source code of a Discord bot for a client. As such I won't be able to provide the full source files as the vast majority of the code isn't mine and I'd rather not release the client's code just in case - but I'll be posting the snippets written by me that are relevant to the question.
The task involves making the bot generate an image highlighting the 'daily' items in the Fortnite game shop. Basically, a background/template image, which will have the images of various shop items overlayed onto boxes in the template image. To accomplish this, I've been attempting to use Jimp for the image manipulation/generation involved. However, I've run across a strange issue that only seems to be a problem when the images came from the API that provides the Fortnite item pngs.
This API returns (among other things) a URL to the image, which was what I initially tried to use to read from with Jimp. (Note that I can't actually provide any links to the API docs as it's in a closed beta; I only have access to it because the client gave me their token so I could work on it.) Jimp.read is meant to take an img URL that it processes into a Jimp image - and this seems to work fine when I use an image URL from any other source. When feeding it the URL from this API, though, it causes an exception which console.logs as:
AssertionError [ERR_ASSERTION]: zlib binding closed
(followed by the rest of a stack trace, which I'll post in full down below).
I've been beating my head against a wall for several hours now trying to break through this, Googling, trying to create workarounds, try out alternative libraries, but have still not been able to get anywhere. I tried loading the image into a Buffer and feeding that into Jimp.read, but get the exact same error, word for word. Tried using the new Jimp( ... ) constructor instead but still didn't work.
I've also been Googling to try and find an answer but the zlib binding closed error seems to be extremely uncommon and there were very few mentions of it in any context, and no mentions of it in relation to Jimp that I could find. Googling "zlib binding closed" within quotes provided me only 19 results period. If nothing else, if anyone knows what this error means, that would help me have a better idea where to look to fix it.
I've tried looking into alternatives to the Jimp library, but as far as JavaScript image manipulating libraries go, the Canvas API requires a DOM object and Caman I just couldn't get to install.
I don't generally ask things on StackOverflow but I couldn't find instances of this problem anywhere. Possible solutions or even just explanations of what the error could mean would be extremely helpful, also if anyone has suggestions for a good alternative to Jimp in the case I can't fix this.
(Code snippets/stack traces below, I probably missed some important stuff since I'm tired and completely brainfried from working on this, so let me know if you need anything else from me)
URL Attempt:
Jimp.read("https://image.fnbr.co/outfit/5b90ec38262b40c2dcc98379/icon.png")
.then(image => {
message.channel.send("jimp", {
file: image
});
})
.catch(err => {
console.log(err);
});") // Should just return a URL string
.then(image => {
message.channel.send("jimp", {
file: image
});
})
.catch(err => {
console.log(err);
});
Buffer Attempt:
request.get("https://image.fnbr.co/outfit/5b90ec38262b40c2dcc98379/icon.png", function(error, response, body) {
if (!error && response.statusCode == 200) {
var buffer = new Buffer(body);
Jimp.read(buffer)
.then(image => {
message.channel.send("jimp", {
file: image
});
})
.catch(err => {
console.log(err);
});
} else {
console.log("8(");
}
});
^ Ultimately the above will be getting the image URLs based on the 'daily' results from the shop but for now I'm just trying to get them to work on a hard-coded URL. All URLs from that API follow the same format as the one used here.
Full console.log(err) Console Output:
{ AssertionError [ERR_ASSERTION]: zlib binding closed
at Inflate._processChunk (C:\Users\(user)\Documents\dev\(project)\node_modules\pngjs\lib\sync-inflate.js:108:3)
at zlibBufferSync (C:\Users\(user)\Documents\dev\(project)\node_modules\pngjs\lib\sync-inflate.js:151:17)
at inflateSync (C:\Users\(user)\Documents\dev\(project)\node_modules\pngjs\lib\sync-inflate.js:155:10)
at module.exports (C:\Users\(user)\Documents\dev\(project)\node_modules\pngjs\lib\parser-sync.js:79:20)
at Object.exports.read [as image/png] (C:\Users\(user)\Documents\dev\(project)\node_modules\pngjs\lib\png-sync.js:10:10)
at Jimp.parseBitmap (C:\Users\(user)\Documents\dev\(project)\node_modules\#jimp\core\dist\utils\image-bitmap.js:117:53)
at new Jimp (C:\Users\(user)\Documents\dev\(project)\node_modules\#jimp\core\dist\index.js:425:32)
at _construct (C:\Users\(user)\Documents\dev\(project)\node_modules\#jimp\core\dist\index.js:100:393)
at C:\Users\(user)\Documents\dev\(project)\node_modules\#jimp\core\dist\index.js:885:5
at Promise (<anonymous>)
generatedMessage: false,
name: 'AssertionError [ERR_ASSERTION]',
code: 'ERR_ASSERTION',
actual: undefined,
expected: true,
operator: '==',
methodName: 'constructor' }
Managing packages with npm, running from a Windows computer.
I was having the same issue.
In my case I was testing with node 10.15.3 but when I pkged my app, the node version embedded was on version 8. Since ZLIB is not available in that version, the assert failed. That is the reason why I was seeing the error.

VS2015 Cordova Sms Plugin Sms.Send doesn't work in Index.JS (ondeviceReady)

I'm new to Cordova, any help would be appreciated.
I created a new Cordova Project in VS2015 and added the Cordova SMS plugin to my project (https://www.npmjs.com/package/cordova-sms-plugin).
I added this code to /www/scripts/index.js function onDeviceReady (as per documentiation for plugin):
function onDeviceReady() {
// Handle the Cordova pause and resume events
document.addEventListener( 'pause', onPause.bind( this ), false );
document.addEventListener( 'resume', onResume.bind( this ), false );
var numberString = "aoeuaeu";
var bypassAppChooser = true;
//CONFIGURATION
var options = {
replaceLineBreaks: false,
android: {
intent: 'INTENT' // send SMS with the native android SMS messaging
}
};
var successSMS = function () { alert('Message sent successfully'); };
var errorSMS = function (e) { alert('Message Failed:' + e); };
sms.send("0811231234", "Testing123", options, successSMS, errorSMS);
I debug the project using Debug, Android, Ripple - Nexus (Galaxy) selected options. When I place a breakpoint on the sms.send line of code and I add a watch for 'sms.send', I can see the object exists.
When I single step, this line in sms.js seems to be the last line that executes:
// fire
exec(
success,
failure,
'Sms',
'send', [phone, message, androidIntent, replaceLineBreaks]
);
I then get the following error message in Ripple:
'Sms.send We seem to be missing some stuff :( What is kinda cool though you can fill in the textarea to pass a json object to the callback you want to execute).'
I can see that all of the objects in that line is defined (success, failure, phone, message, androidIntent, replaceLineBreaks). When I 'step into' this line, it continues to execute code in ripple.js, but it becomes hard to follow for a person, since there are no line breaks in this file.
What am I doing wrong? I've read through all the documentation I can find & searched stackoverflow questions and can't seem to find any solutions to the problem.
I've uploaded this entire project (zipped), which can be downloaded at:
https://drive.google.com/file/d/0BwWgTMh-JLbfNHV0MlE5Yk5IZ3M/view?usp=sharing
Thanks in advance
Thank you Cordova team at Microsoft for helping me with an answer:
"Ripple has the ability to emulate some but not all plugins. SMS is not one of the plugins that it can fully emulate. However, in the message that pops up, you do have the ability to hit the Success or Fail buttons which will report back to the app that it was successful or not in sending the SMS. While that doesn’t actually send a message, it does let you test your app to see how it behaves for different results.
I tried the bit of sample code you included in the first email. In Ripple, I was able to change the alert by hitting the different buttons.
Trying other deployment methods, in both the VS Android Emulator and the Google Emulator they showed failure alert messages that they don’t support SMS messages. I then launched it on an Android phone device and it said it was successful.
So I believe your options are mainly using Ripple to fake sending of messages or using a device for testing."

Categories

Resources