node-flickrapi icon indicating copy to clipboard operation
node-flickrapi copied to clipboard

Node hangs using Flickr.authenticate

Open colophonemes opened this issue 8 years ago • 4 comments

When using the Flickr.authenticate method, everything behaves as expected (authentication, making API calls) but the Node process won't exit by itself.

This seems similar to what @cheapsteak was experiencing in #71 here

Here's a sample application that reproduces the behaviour:

var habitat = require('habitat')
var env = habitat.load(__dirname+'/../.env'); // based on the sample .env file
var Flickr = require('flickrapi')

Flickr.authenticate(env.get('flickr'),function(err, flickr) {
    if (err) throw err;
    flickr.photos.search({
        user_id: flickr.options.user_id,
        page: 1,
        per_page: 20,
        extras: ['description','license','url_m'],
        authenticated: true
    }, function(err, result) {
        if (err) throw err;

        result.photos.photo.forEach(function(photo){
            console.log(photo)
        })
    });
});

colophonemes avatar Jan 31 '16 11:01 colophonemes

thanks, I'm going to see if I can figure out which callback is kept open...

Pomax avatar Jan 31 '16 19:01 Pomax

I'm using Flickr.tokenOnly(...) but I've also had the process not exit by itself. But I figured out that if I disable the progress bar in the options it exits correctly. So maybe it's the progress bar that keeps the process running? I haven't tried Flickr.authenticate() though.

const flickrOptions = {
  api_key:  'lol',
  secret:   'yolo',
  progress: false
};

Flickr.tokenOnly(flickrOptions, function(err, flickr) {
  // ...
});

maxkueng avatar Jul 03 '16 21:07 maxkueng

Interesting, I'll strip the progress bar and see if that makes a difference for the plain auth code too. Good find.

Pomax avatar Jul 04 '16 17:07 Pomax

I can also confirm that this is related to setting the progress param in flickrOptions when calling tokenOnly. I was debugging stalled tests and was led to flickrapi, set progress: true (true accidentally), and the tests stopped hanging. I would like to propose setting the default option to false so as to minimize unexpected logging.

ox avatar Jul 30 '16 05:07 ox