Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Jun 19 22:05
    demangejeremy starred balderdashy/sails
  • Jun 19 10:29
  • Jun 19 10:01
    michael-tomala synchronize #1601
  • Jun 18 23:13
    NestorInHawaii starred balderdashy/sails
  • Jun 18 15:14
    shreyas-mallya edited #7131
  • Jun 18 15:07
    sailsbot commented #7131
  • Jun 18 15:07
    shreyas-mallya opened #7131
  • Jun 18 14:43
    arvidede starred balderdashy/sails
  • Jun 18 13:22
    sailsbot unlabeled #6797
  • Jun 18 13:22
    alambertt commented #6797
  • Jun 17 17:49
    pig-big starred balderdashy/sails
  • Jun 17 12:52
  • Jun 16 13:39
    reginaldobertoluci starred balderdashy/sails
  • Jun 16 06:04
    hitjethva commented #7130
  • Jun 16 05:25
    sailsbot commented #7130
  • Jun 16 05:25
    sailsbot unlabeled #7130
  • Jun 16 05:25
    hitjethva edited #7130
  • Jun 16 05:15
    sailsbot labeled #7130
  • Jun 16 05:15
    sailsbot commented #7130
  • Jun 16 05:15
    hitjethva opened #7130
brookesb91
@brookesb91
balderdashy/sails#4339
it’s easily repro'd
Even if i don’t use .catch() or .then() for queries and just assign them to a variable I get the exact same issue.
brookesb91
@brookesb91
Managed to report it again more simply…
module.exports = {
    friendlyName: 'Get One Record',
    description: 'Gets one record',
    inputs: {
        id: {
            type: 'number',
            required: true
        }
    },
    exits: {
        success: {
            statusCode: 200,
            responseType: ''
        },
        notFound: {
            statusCode: 404,
            responseType: ''
        }
    },
    fn: async function (inputs, exits) {
        const result = await sails.helpers.getById(inputs.id).intercept('recordNotFound', () => {
            return exits.notFound();
        });

        return exits.success(result);
    }
}
and my helper…
module.exports = {
    friendlyName: 'Get Record By Id',
    description: 'Retrieves a single record by Id',
    inputs: {
        id: {
            type: 'number',
            required: true
        }
    },
    exits: {
        recordNotFound: {
            description: 'The specified record was not found'
        }
    },
    fn: async function(inputs, exits) {
        let result = await TestModel.findOne({id: inputs.id});

        if(_.isUndefined(result)){
            throw 'recordNotFound';
        }
        return exits.success(result);

    }
};
is this similar to your issue still? @marcoreni
Marco
@marcoreni
Yes it's similar. I'm trying to see if the problem shows also simplyfing your example further by not intercepting the error on the controller and returning, helper-side, an error already handled by the controller..
brookesb91
@brookesb91
Let me know what you figure out! I’d appreciate it
Marco
@marcoreni
@brookesb91 are you using Typescript? It seems that most of my problems are solved if I revert back to JS
brookesb91
@brookesb91
@marcoreni I am not
Marco
@marcoreni

I tried your simplified example. The issue is solved if you change your controller function to:

fn: async function (inputs, exits) {
        const result = await sails.helpers.getById(inputs.id)
          .intercept('recordNotFound', 'notFound');

        return exits.success(result);
    }

(basically letting Sails do all the work on the error handling). Probably the documentation on .intercept() is wrong?

brookesb91
@brookesb91
@marcoreni brilliant, I’ll try that… I think you’re right there - it almost feels like they’re being handle by the machine helpers but when we expect them we’re essentially re-throwing them - causing more errors and double exits… That’s what it feels like anyway … I’d love to be told either way.
Marco
@marcoreni
I also found out that if my helper throws an error with a custom responseType, this is encapsulated and client-side I'll receive a 500 error. For example, if I have a noResults custom exit (with responseType: 'noResults') inside the helper, I have to .intercept('noResults', 'noResults') on the controller in order to have the correct response clientSide. I don't know if this is a bug
brookesb91
@brookesb91
@marcoreni I guess the actual intercepting is done using that then… So intercept will only intercept an error of a certain type as long as it is defined as a response type in the helper? That’s the impression I’m getting
Marco
@marcoreni
I defined it as a specific exit with a specific responseType, but nonetheless externally it's incapsulated in a standard serverError
Ranganadh Paramkusam
@vssranganadhp
Where can we set maximum timeout for a rest call?
brookesb91
@brookesb91
@marcoreni Thought as much - you can see the error type as serverError in the stack trace before the double exit error - cheers for your help
@vssranganadhp I believe that can be set with custom middleware - have a look at the docs - I believe there was an example on there
Rohit Gupta
@rohitgmait
I have a query regarding sails.socket client
Is there any way i can use socket.io client with socket running embedded in sails server?
var socket = io([sails server]) is not working
Oliver Kühne
@oliverkuehne
i upgrade my mongodb from 3.4 to 3.6 after this, my sails app get this error:
MongoError: The 'cursor' option is required, except for aggregate with the explain argument anyone else who gets this and how can i fix this?
Mike McNeil
@mikermcneil
@/all Hey everybody! Just published a patch that adds a (development-mode only) warning if a Deferred is not executed (i.e. await, .exec(), .then(), etc.) within 15 seconds. It isn't the solution of our dreams, but it's the best thing we could come up with to help prevent confusing bugs resulting from forgetting to type await.
@oliverkuehne hmm- can't take a look right now, but will try my best to investigate that. Would you mind making an issue if you haven't already?
Mike McNeil
@mikermcneil
@brookesb91 .intercept() negotiates an error and then lets you do something with it -- in the example above, we're using a combination of special shorthand and "special exit signals" to turn it into a one-liner. All it's really doing is intercepting an error with a code of recordNotFound, if that helper happens to throw one. And then, if it does, the .intercept() call is doing throw 'notFound' -- which is just a simpler way of writing return exits.notFound()

Another example-- these are all basically the same thing:

.intercept('E_UNIQUE', 'emailAlreadyInUse')
.intercept('E_UNIQUE', ()=>'emailAlreadyInUse')
.intercept('E_UNIQUE', ()=>{ return 'emailAlreadyInUse'; })
try {
  // …
} catch (err) {
  if (err.code === 'E_UNIQUE') {
    throw 'emailAlreadyInUse';
  } else { throw err; }
try {
  // …
} catch (err) {
  if (err.code === 'E_UNIQUE') {
    return exits.emailAlreadyInUse();
  } else { return exits.error(err); }

^ but as you can see that gets pretty wordy. That's what the shorthand is for

Make It Count
@makeitcount
@entvikas sorry for the delayed response. feel free to share the problem and how may I help. Will reply as soon as possible
brookesb91
@brookesb91
@mikermcneil cheers, you’re awesome
smihaljenovic
@smihaljenovic
Is there any new info about "deep" sort/queries on models?
balderdashy/waterline#1519
I tried solution from this pull, but it's not working.
I'm using sails 1.0.0-46, waterline 0.13.1
Eden Corbin
@edencorbin
I have used https://www.npmjs.com/package/connect-pg-simple for session store in the past, but cannot dig up my adaptor settings, anyone storing session data in postgres in sails 1.0+ and have an example npm install / adapter settings they could share?
jp pincheira
@pincheira
Hi guys. :) I just started a migration from 0.12 to 1.0. I'm trying to call a private method declared inside a controller from an action within the same controller, but it's not reachable anymore. Do you know of a way to call it again? I use to call the method just with this.methodName(). It's controller-specific, so I don't want to put it outside on a helper service.
paulogdm
@paulogdm
Guys, you looking to move to https://spectrum.chat/ ?
paulogdm
@paulogdm
*on moving to
|56|69|6B|61|73|20|4B|61|6E|64|77|61|6C|D|A|56|69|6B|61|73|0D
@entvikas
Dear @mikermcneil the sails framework is criticised for poor documentation, but after reviewing your book on sails I really didn't find the documentation important but from a startup and developer perspective poor documentation and undeclared roadmap plus a inactive web portal (inactive in the sense of no members communication) of the technology seems like a confusing one for some one new. I suggest you to increase the conversation on the main website as well as push community members to post there feature requests and reviews over there like ember does .. that will increase the adoption of the framework in a steady manner...
@paulogdm naaaaa
Arthur
@atishkevich

Hi, I'm new with SailsJS. Maybe here anyone can help me? I'm trying to combine sailsjs with firebase functions.

Firebase functions transfer all request through

functions.https.onRequest((req, res) => {
    ...
});

So when I'm trying to run sails app in firebase environment all http calls don't get sails app. How can I pass to sails app these requests?
I tried to access somehow to sails.hooks.https.app but had no luck.

Appreciate for any help.

Lalit Indoria
@lalitindoria
Does anyone know how to override blueprints actions using actions2? I have a find-one.js inside my controller directory but it doesn't get trigged when accessing /controllerName/1
Eden Corbin
@edencorbin
@pincheira regarding your calling a method, I recommend putting that in a service, or I suppose actions in 1.0+ (services are still supported though). I set globals.js services: true, then have an api/services folder, then just call myService.myFunction and define your function in the service: myFunction: function (){}. To my knowledge you can't call a method in the same controller unless it is inside the action you are calling it from.
Mike DeVita
@mikedevita
in 0.12x on a Model.update() it's returning an array even if I'm only updating a single item.
is there another method I should be using ... maybe like updateOne()?
or should I just do updatedItem[0]?
Vishal Sinha
@iVishalSinha_twitter
Hi i am new in sails.js I have a problem with relation is sails.js using mongodb
There is two model : user and mymaster. Both has a table name tempData & mymaster respectively. user has id and mymaster has userId attribute. Now i want get all the details of user with id and parallaly mymaster details of that user . user has tempData table and mymaster has mymaster table. Now please let me know how do i perform this operation.
Mike DeVita
@mikedevita
i am trying to get sessions to work with my unit tests, using supertest like the concepts show.
But i dont think supertesst supports sessions
nvm looks like i can use request = require(‘supertest’).agent(appurl) but i am not sure what to put in place of appurl
xmgdtc
@xmgdtc
hi everyone
I wants to use mocha in sails, and i require a config files const blueprints=sails.config.blueprints; in a services. I have the bootstrap.test.js. when i run the mocha. There was an err Cannot read property 'blueprints' of undefined . how to resove this.
Mike McNeil
@mikermcneil
@smihaljenovic Unfortunately, no new WHERE subqueries or "deep sort" features in Sails v1 -- you've still got to use multiple queries or do a native query