MeteorJS server crash complaining Error: ENOENT: no such file or directory, open '..../cfs/files/_tempstore/..chunk' - heroku

Recently, we created a new upload image/PDF function.
When someone uploaded a PDF, the server still worked. But after a daily restart, the server kept crashing:
2022-05-25T00:52:13.648659+00:00 app[web.1]: (node:3) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
2022-05-25T00:52:13.747819+00:00 app[web.1]: internal/streams/legacy.js:61
2022-05-25T00:52:13.747821+00:00 app[web.1]: throw er; // Unhandled stream error in pipe.
2022-05-25T00:52:13.747821+00:00 app[web.1]: ^
2022-05-25T00:52:13.747821+00:00 app[web.1]:
2022-05-25T00:52:13.747822+00:00 app[web.1]: [Error: ENOENT: no such file or directory, open '/app/.meteor/heroku_build/cfs/files/_tempstore/retailerRegistrationMedia-w6e6Kxgy8QLTgirET-0.chunk'] {
2022-05-25T00:52:13.747822+00:00 app[web.1]: errno: -2,
2022-05-25T00:52:13.747823+00:00 app[web.1]: code: 'ENOENT',
2022-05-25T00:52:13.747823+00:00 app[web.1]: syscall: 'open',
2022-05-25T00:52:13.747835+00:00 app[web.1]: path: '/app/.meteor/heroku_build/cfs/files/_tempstore/retailerRegistrationMedia-w6e6Kxgy8QLTgirET-0.chunk'
2022-05-25T00:52:13.747836+00:00 app[web.1]: }
Investigating further, it appears that if we delete last record from the cfs._tempstore.chunks collection, the server can then starts correctly.
Also, the crash ONLY happens, if the uploaded media is a PDF. No crash if uploaded media is image
What is the cause of this error?
Relevant code to save an image below:
Meteor.utilities.addRetailerRegistrationMediaFile(e, function(fileId){
if(e.target.id == "companyACRAFile"){
tpl.companyACRAFile = fileId;
}else if(e.target.id == "companyShopPhotos"){
tpl.companyShopPhotos.push(fileId);
console.log("tpl.companyShopPhotos", tpl.companyShopPhotos);
}
});
Meteor.utilities.addRetailerRegistrationMediaFile = function (e, callback) {
var $target = $(e.currentTarget)
FS.Utility.eachFile(e, function (file) {
RetailerRegistrationMediaObjects.insert(file, function (err, fileObj) {
if (err) {
return throwError(err);
}else{
callback(fileObj._id);
}
});
});
};
// For all retailer application media
RetailerRegistrationMediaObjects = new FS.Collection("retailerRegistrationMedia", {
stores: [
new FS.Store.S3("registrationThumbs", {
region: settings.public.aws_region,
accessKeyId: settings.public.aws_key_id,
secretAccessKey: settings.public.aws_access_key,
bucket: settings.public.aws_bucket,
folder: "registration/thumbs",
transformWrite: createThumbIfImage,
}),
new FS.Store.S3("registration", {
region: settings.public.aws_region,
accessKeyId: settings.public.aws_key_id,
secretAccessKey: settings.public.aws_access_key,
bucket: settings.public.aws_bucket,
folder: "registration",
}),
],
filter: {
maxSize: 5000000, //in bytes
allow: {
contentTypes: ["image/*", "application/pdf"],
},
onInvalid: function (message) {
if (Meteor.isClient) {
// prepare the data for notification
sAlert.error(message);
}
},
},
});
RetailerRegistrationMediaObjects.allow({
insert: function (userId, doc) {
return true;
},
update: function (userId, doc, fieldNames, modifier) {
return true
},
remove: function (userId, doc) {
return true
},
download: function (userId) {
return true;
},
});

Related

My friend is making a websocket server and it's not working

My friend made this WebSocket server for MineCraft and it doesn't work. He won't be on for a while so I decided to come to here. Can anyone help?
// Minecraft Bedrock WebSocket Server
const webSocket = require('websocket');
const readline = require('readline');
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
const wss = new webSocket.server({port: 8000 });
try {
console.log("Server is running on your_ip:8000");
wss.on('connection', socket => {
console.log("A client is opening a connection");
const command = () => {
return new Promise((resolve) => {
rl.question(`Command: /`, (cmd) => {
// log user details
//console.log(`\nYour INPUT: /${cmd}`);
// Send command
socket.send(JSON.stringify(
{
"body": {
"origin": {
"type": "player"
},
"commandLine": `${cmd}`,
"version": 1
},
"header": {
"requestId": "00000000-0000-0000-0000-000000000000",
"messagePurpose": "commandRequest",
"version": 1,
"messageType": "commandRequest"
}
}
));
console.log("Command sent\n\n");
resolve();
});
});
}
async function askCommands() {
while (true) {
await command();
}
}
// Run async function
askCommands();
socket.on('message', function incoming(message) {
console.log('\nreceived: %s', message);
});
process.on('SIGINT', function() {
console.log("\nInterrupt Ctrl-C");
process.exit();
});
});
wss.off;
} catch(E) {
console.log(E);
}
This is the error in Visual Studio Code:
Debugger attached.
Waiting for the debugger to disconnect...
c:\Users\*****\Downloads\wsserver-bedrock-master\wsserver-bedrock-master\node_modules\websocket\lib\WebSocketServer.js:150
throw new Error('You must specify an httpServer on which to mount the WebSocket server.');
^
Error: You must specify an httpServer on which to mount the WebSocket server.
at WebSocketServer.mount (c:\Users\*****\Downloads\wsserver-bedrock-master\wsserver-bedrock-master\node_modules\websocket\lib\WebSocketServer.js:150:15)
at new WebSocketServer (c:\Users\*****\Downloads\wsserver-bedrock-master\wsserver-bedrock-master\node_modules\websocket\lib\WebSocketServer.js:36:14)
at Object.<anonymous> (c:\Users\*****\Downloads\wsserver-bedrock-master\wsserver-bedrock-master\wsserver.js:11:13)
at Module._compile (internal/modules/cjs/loader.js:1068:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1097:10)
at Module.load (internal/modules/cjs/loader.js:933:32)
at Function.Module._load (internal/modules/cjs/loader.js:774:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
at internal/main/run_main_module.js:17:47
Process exited with code 1
Uncaught Error: You must specify an httpServer on which to mount the WebSocket server.
No debugger available, can not send 'variables'
Hi you just code like this.
In Client Side code should be like
REF
And Server will be like this
REF 2:

Heroku/Nuxt not picking up on a mixin?

I have a button that re-directs to a stripe checkout page - which works fine on my local machine, but I'm receiving this error in my heroku logs when I try it out in production:
2021-04-07T14:22:30.664437+00:00 app[web.1]:
2021-04-07T14:22:30.664454+00:00 app[web.1]: ERROR Cannot read property 'subscriptions' of null
2021-04-07T14:22:30.664454+00:00 app[web.1]:
2021-04-07T14:22:30.664455+00:00 app[web.1]: at a.checkActiveSubscription (mixins/stripeSubscription.js:10:0)
2021-04-07T14:22:30.664455+00:00 app[web.1]: at a.hasAnyActiveSubscription (pages/profile/billing/index.vue:186:0)
2021-04-07T14:22:30.664456+00:00 app[web.1]: at a.hasAnyActiveSubscription (node_modules/vue/dist/vue.runtime.common.prod.js:6:29698)
2021-04-07T14:22:30.664457+00:00 app[web.1]: at a.render (pages/profile/billing/index.vue)
2021-04-07T14:22:30.664457+00:00 app[web.1]: at a.t._render (node_modules/vue/dist/vue.runtime.common.prod.js:6:35273)
2021-04-07T14:22:30.664458+00:00 app[web.1]: at node_modules/vue-server-renderer/build.prod.js:1:70637
2021-04-07T14:22:30.664458+00:00 app[web.1]: at Yi (node_modules/vue-server-renderer/build.prod.js:1:67201)
2021-04-07T14:22:30.664458+00:00 app[web.1]: at io (node_modules/vue-server-renderer/build.prod.js:1:70613)
2021-04-07T14:22:30.664458+00:00 app[web.1]: at ro (node_modules/vue-server-renderer/build.prod.js:1:70244)
2021-04-07T14:22:30.664459+00:00 app[web.1]: at eo (node_modules/vue-server-renderer/build.prod.js:1:67491)
2021-04-07T14:22:30.664459+00:00 app[web.1]:
Index.vue:
import checkActiveSubscription from "#/mixins/stripeSubscription.js";
export default {
mixins: [checkActiveSubscription],
....
}
computed: {
hasAnyActiveSubscription() {
return this.checkActiveSubscription();
},
stripeSubscription.js:
export default {
methods: {
checkActiveSubscription() {
/*
check if user has any active subscription
if so, the user should be able to manage their existing billing
else - show buttons to create new subscription plans
*/
let subscriptions = this.$store.getters.user.subscriptions;
let hasActiveSubscription = false;
subscriptions.some((element, index) => {
if (element.status == "active") {
hasActiveSubscription = true;
}
});
return hasActiveSubscription;
},
}
}
Any pointers? Is the issue on Nuxt, Stripe, or Heroku?
My Nuxt store looks like this (user.js inside a folder called store):
export const state = () => ({
CSRFToken: null,
isLoggedIn: false,
user: null,
})
export const mutations = {
setCSRFToken(state, token) {
state.CSRFToken = token
},
setLoggedIn(state, bool) {
state.isLoggedIn = bool
},
setUser(state, user) {
state.user = user
},
}
export const actions = {
async nuxtServerInit(vuex, context) {
console.log("hello?")
const user = await context.app.$axios.$get(`/account/session/`, {
credentials: "include",
});
vuex.dispatch("setLoggedIn", user.isAuthenticated);
const { data, headers } = await this.$axios.get('/account/csrf/', {
withCredentials: true
});
const csrfToken = headers["x-csrftoken"];
vuex.dispatch("setCSRFToken", csrfToken)
if (user.isAuthenticated) {
const userDetails = await context.app.$axios.$get(`/account/current/`, {
headers: {
"X-CSRFToken": csrfToken
},
});
vuex.dispatch("setUser", userDetails);
}
},
setCSRFToken({ commit }, token) {
commit("setCSRFToken", token);
},
setLoggedIn({ commit }, bool) {
commit("setLoggedIn", bool)
},
setUser({ commit }, user) {
commit("setUser", user)
}
}
export const getters = {
CSRFToken: state => {
return state.CSRFToken
},
isLoggedIn: state => {
return state.isLoggedIn
},
user: state => {
return state.user
}
}
and the user is fetched in a computed property as such:
user() {
return this.$store.getters.user;
},

FineUploader 5.14.0 - setParams not working with large files

I've had the following code working for quite a while now (over a year) but a user has tried to upload a 14MB file and the extra data I post along with the upload seems to not get posted anymore.
In Chrome dev tools I look at the header of the (single) XHR and I see the data in the "Form data" section but nothing get's to the server which I don't understand.
Files that are a few MB or smaller work without issue. I've not found a magic MB limit yet.
The extra data is in the onUpload call back. board_hash is in the head of page.
var fu_instance = new qq.FineUploader(
{
element: $uploader[0],
template: 'agenda_file_template',
debug: true,
request: {
endpoint: '/m/upload',
forceMultipart: false,
customHeaders: {
Accept: 'application/json'
}
},
autoUpload: false,
messages:
{
noFilesError: "There is no files to upload. Select or drag and drop some files to upload.",
},
failedUploadTextDisplay:
{
mode: 'custom',
responseProperty: 'error'
},
callbacks:
{
onSubmit: function(id, filename)
{
// File added to upload
$uploader.addClass('hide-drop-msg');
$btn_submit_upload.html('Upload').show();
unsaved = true;
},
onUpload: function(id, name)
{
fu_instance.setParams({'board_hash': board_hash, 'parent': $parent.val()});
},
onCancel: function(id, name)
{
// Actually onBeforeCancel
if ($uploader.find('ul.qq-upload-list li').length == 1)
{
// There is currently 1 & it's about to be axed
$uploader.removeClass('hide-drop-msg');
$btn_reset_uploads.hide();
$btn_submit_upload.html('Upload').show();
unsaved = false;
}
},
onError: function(id, name, reason, resp)
{
// Specific file error
if (resp.hasOwnProperty('auth_expired'))
{
window.location.href = auth_url;
}
},
onComplete: function(id, name, resp)
{
if (resp.success)
{
var $parent_el = $('#'+$parent.val());
$parent_el.find('.files').append(resp.html);
$parent_el.find('.no-agenda-files').hide();
}
},
onAllComplete: function(succeeded, failed)
{
// Every file is done
$btn_submit_upload.hide();
$btn_reset_uploads.show();
unsaved = false;
}
}
});
My understanding is that chunking is off by default. Have I configured this wrong or am I in the wrong call back?

goolge api error { domain: 'androidpublisher', reason: 'noApks', message: 'This app has no APKs.' }

I followed the link here http://frontendcollisionblog.com/javascript/2015/12/26/using-nodejs-to-upload-app-to-google-play.html to use node to upload apk to googleapi. I always got this error
errors:
[ { domain: 'androidpublisher',
reason: 'noApks',
message: 'This app has no APKs.' } ]
This is my upload function
function upload(data) {
var edit = data.edit;
var apk = data.apk;
console.log("upload" + edit.data.id);
return new Promise(function(resolve, reject) {
play.edits.apks.upload({
editId: edit.data.id,
media: {
mimeType: 'application/vnd.android.package-archive',
body: apk
}
}, function(err, res) {
if(err || !res) {
reject(err);
}
resolve(_.omit(_.extend(data, { uploadResults: res }), 'apk'));
});
});
}
Anyone know what the error is and how to fix it?

Error TypeError: Cannot read property 'dispatch' of undefined at app.js:12012

Hi I've been trying to learn vuejs and vuex while trying to get response from an api call with vuex concept I got the following error.Please help.
This error occurred
Error TypeError: Cannot read property 'dispatch' of undefined
at app.js:12012
loginAction.js
export const getUsersList = function (store) {
let url = '/Apis/allUsers';
Vue.http.get(url).then((response) => {
store.dispatch('GET_USER_RES', response.data);
if (response.status == 200) {
}
}).catch((response) => {
console.log('Error', response)
})
}
loginStore.js
const state = {
userResponse: []
}
const mutations = {
GET_USER_RES (state, userResponse) {
state.userResponse = userResponse;
}
}
export default {
state, mutations
}
login.vue
import {getUsersList} from './loginAction';
export default {
created () {
try{
getUsersList();
}catch(e){
console.log(e);
}
},
vuex: {
getters: {
getUsersList: state => state.userResponse
},
actions: {
getUsersList
}
}
}
</ script>
If you call the actions manually (like in your try/catch) they'll not get the store context as the first argument. You could use getUsersList(this.store) I think, but instead I would use dispatch to reach all your actions. (I edited just a little bit to get a minimal running example, but I think you get the point!)
new Vue({
render: h => h(App),
created() {
this.$store.dispatch('getUsersList');
},
store: new Vuex.Store({
getters: {
getUsersList: state => state.userResponse
},
actions: {
getUsersList
}
})
}).$mount("#app");
Also, use commit to reach the mutations instead of dispatch. ie:
export const getUsersList = function ({commit}) {
let url = '/Apis/allUsers';
Vue.http.get(url).then((response) => {
commit('GET_USER_RES', response.data); // because GET_USER_RES is a mutation
...

Resources