Declaring slingshot on the server causes app to crash - meteor-slingshot

On the client I have:
'change #banner_input': function(){
event.preventDefault();
var uploader = new Slingshot.Upload("myFileUploads");
Slingshot.fileRestrictions("myFileUploads", {
allowedFileTypes: ["image/png", "image/jpeg", "image/gif"],
maxSize: 10 * 1024 * 1024 // 10 MB (use null for unlimited).
});
var fileO = event.target.files[0];
console.log(fileO);
uploader.send(fileO, function (error, downloadUrl) {
if (error) {
// Log service detailed response.
console.error('Error uploading', uploader.xhr.response);
}
else {
alert(downloadUrl);
// Meteor.users.update(Meteor.userId(), {$push: {"profile.files": downloadUrl}});
}
});
}
But when I add this to the server ,even "empty" for debugging, app crashes:
Slingshot.createDirective("myFileUploads", Slingshot.S3Storage, {
});
The error I get:
AppData\Local.meteor\packages\meteor-tool\1.1.10\mt-os.windows.x86_32\dev_bundle\server-lib\node_modules\fibers\future.js:245
W20160212-11:50:43.857(2)? (STDERR) throw(ex);
W20160212-11:50:43.857(2)? (STDERR) ^
W20160212-11:50:43.858(2)? (STDERR) Error: Match error: Failed Match.Where validation in field region
W20160212-11:50:43.858(2)? (STDERR) at check (packages/check/match.js:33:1)
W20160212-11:50:43.858(2)? (STDERR) at new Slingshot.Directive (packages/edgee_slingshot/packages/edgee_slingshot.js:304:1)
W20160212-11:50:43.858(2)? (STDERR) at Object.Slingshot.createDirective (packages/edgee_slingshot/packages/edgee_slingshot.js:274:1)
W20160212-11:50:43.858(2)? (STDERR) at server/slingshot.js:5:1
W20160212-11:50:43.859(2)? (STDERR) at server/slingshot.js:23:1
W20160212-11:50:43.859(2)? (STDERR) at somepath.meteor\local\build\programs\server\boot.js:242:10
W20160212-11:50:43.859(2)? (STDERR) at Array.forEach (native)
W20160212-11:50:43.859(2)? (STDERR) at Function..each..forEach (somepath.meteor\packages\meteor-tool\1.1.10\mt-os.windows.x86_32\dev_bundle\server-lib\node
_modules\underscore\underscore.js:79:11)
W20160212-11:50:43.860(2)? (STDERR) at path.meteor\local\build\programs\server\boot.js:137:5
Thanks for your help.

Error: Match error: Failed Match.Where validation in field region
Region causes the error.
Read this for region codes : http://docs.aws.amazon.com/general/latest/gr/rande.html#s3_region
And try changing it from your properties.

Related

Electron - Uncaught (in promise) Error: An object could not be cloned

I've this error when I click on my button:
Uncaught (in promise) Error: An object could not be cloned.
I start with electron, and I would like to take advantage of this topic to know the difference between invoke and send (I tried both, with the same error)
Main.js
ipcMain.handle('savePdf', (event, pdfFile) => {
console.log(event);
console.log(pdfFile);
return pdfFile;
}
preload.js
contextBridge.exposeInMainWorld('pdf', {
savePdf: (file) => ipcRenderer.invoke('savePdf', file),
})
rendered.js
const pdfFileInput = document.getElementById('input-file'); // OK
const pdfFile = pdfFileInput.files[0]; // OK
console.log(pdfFile); // OK
await pdf.savePdf(pdfFile);

Apollo Client on React - How to retrieve the error message fomated?

I can't find info about it in anywhere...
Consider this very simple scenario...
<Mutation mutation={LOGIN_MUTATION}>
{(login, { data, loading, error }) => {
if (error) {
console.log(error)
}
I am receiving a string error message like...
Error: GraphQL error: ERROR_INVALID_LOGIN_PROVIDER
at new ApolloError (bundle.umd.js:92)
at MutationData.onMutationCompleted (react-hooks.cjs.js:636)
at react-hooks.cjs.js:559
at tryCallOne (core.js:37)
at core.js:123
at JSTimers.js:289
at _callTimer (JSTimers.js:146)
at _callImmediatesPass (JSTimers.js:194)
at Object.callImmediates (JSTimers.js:458)
at MessageQueue.__callImmediates (MessageQueue.js:366)
I can't take actions based on the error message formated in this way. ERROR_INVALID_LOGIN_PROVIDER could be ERROR_INVALID_PASSWORD, for example...
I need to take decisions based on the error messages. but I just receive a string containing the graphql error, the modules inside the js and a lot of information that's not important. Is there any way to receive the error message formatted imn a way that I can extract only the server error ?
This should be possible
error in your example should be an ApolloError with the possible GraphQLErrors or a NetworkError
(login, { data, loading, error }) => {
if (error) {
if (error.graphQlErrors && error.graphQLErrors.length > 0) {
// There are graphQL errors and there may be multiple but its always an array.
// You should handle it properly
const { message } = error.graphQLErrors[0]
console.log(message) // e.g. ERROR_INVALID_LOGIN_PROVIDER
} else if (error.networkError) {
// There may be a network error
const { message } = error.networkError
console.log(message) // e.g. NetworkError when attempting to fetch resource.
}
}

How to fix 'TypeError: this.isCallback is not a function' error for UserAgentApplication in msal.js

using Msal v1.0.2, loginPopup is not working from iFrame.
trying to get the UserAgentApplication instance using client_id. its throwing an exception:
TypeError: this.isCallback is not a function
at Object.UserAgentApplication (UserAgentApplication.ts:228)
const myMSALObj = Msal.UserAgentApplication(msalConfig);
myMSALObj.loginPopup(["user.read"]).then(function (loginResponse) {
return myMSALObj.acquireTokenSilent(accessTokenRequest);
}).then(function (accessTokenResponse) {
const token = accessTokenResponse.accessToken;
}).catch(function (error) {
//handle error
});
sample from . 'Quickstart for MSAL JS' works fine but when I try to integrate Msal inside iFrame of my JavaScript plugin code, its not working.
working code from sample:
var myMSALObj = new Msal.UserAgentApplication(msalConfig);
myMSALObj.handleRedirectCallback(authRedirectCallBack);
myMSALObj.loginPopup(requestObj).then(function (loginResponse) {
acquireTokenPopupAndCallMSGraph();
}).catch(function (error) {
//Please check the console for errors
console.log(error);
});
there was a typo causing this exception: TypeError: this.isCallback is not a function at Object.UserAgentApplication (UserAgentApplication.ts:228)
fix: const myMSALObj = new Msal.UserAgentApplication(msalConfig);
That should solve this exception issue.

Coinbase-pro for Node.js - Websocket connection breaking with error: read ECONNRESET

I'm currently stuck with an issue I'm getting with the coinbase-pro-node npm package (https://github.com/coinbase/coinbase-pro-node). I'm connecting to the matches channel and listening for messages there but the connection with the Websocket breaks after a few hours without telling me much. I can't trace back the problem and it doesn't happen on the same intervals. Sometimes it breaks just minutes after I run the script. Thanks for the help.
The code:
const CoinbasePro = require('coinbase-pro');
var coinbaseWs = '';
function connect() {
coinbaseWs = new CoinbasePro.WebsocketClient(
['BTC-USD'],
'wss://ws-feed.pro.coinbase.com',
{
key: 'xxxx',
secret: 'xxxx',
passphrase: 'xxxx',
},
{ channels: ['matches'] }
);
coinbaseWs.on('message', async data => {
console.log(data)
});
coinbaseWs.on('error', err => {
console.error("Connection with Coinbase websocket failed with error: " + err);
console.log("Error stack trace: " + err.stack);
});
coinbaseWs.on('close', () => {
console.error("Connection with Coinbase websocket closed!");
});
}
connect();
Error stack:
Error: read ECONNRESET
File "internal/stream_base_commons.js", line 167, in TLSWrap.onStreamRead
it does break from time to time for no apparent reason. All you can do is listen for the heartbeat messages and use those to decide whether to re-initiate a new websocket feed. I raised a similar query directly with the coinbase pro/gdax customer support.

EACCES error when sending datagram on Windows

My program throw an EACCES error when execute send() method of dgram.udp4 socket, but only does it on Windows.
The code:
var dgram = require('dgram');
var monsocket = dgram.createSocket("udp4");
monsocket.on("listening", function () { comBroadcastCallUp(); });
var comBroadcastCallUp = function() {
var message = new Buffer(JSON.stringify({
protocol: "psdp",
command: "call-up"
}));
monsocket.setBroadcast(true);
monsocket.send(message, 0, message.length, 32681, '255.255.255.255', function (err) {
if (err) console.log(err)
else console.log("<PcStatus:PSDP> Message sent: " + message + os.EOL + "Message length: " + message.length);
});
monsocket.setBroadcast(false);
}
monsocket.bind(32681);
Same code, terminal output on Windows:
{ [Error: send EACCES] code: 'EACCES', errno: 'EACCES', syscall: 'send' }
Terminal output on Linux:
<PcStatus:PSDP> Message sent: {"protocol":"psdp","command":"call-up"}
Message length: 39
I check the firewall, if other program kept the port busy, nothing...
Broadcasting to 255.255.255.255 is not supported anymore as of Windows 7 I believe. You will need to limit the send to a particular subnet instead.
Also keep in mind that not all routers will route packets destined for 255.255.255.255.

Resources