hebcal / hebcal-js

⛔️ DEPRECATED - a perpetual Jewish Calendar (JavaScript)
GNU General Public License v3.0
123 stars 40 forks source link

Hebcal hangs indefinitely? #12

Closed mjradwin closed 8 years ago

mjradwin commented 10 years ago

I don't know if I'm doing something wrong here... but the npm module seems to hang after requiring the module.

Can you reproduce this behavior with my 1-liner?

MTVL10d09b0d4:~ mradwin$ cat hebcal-require.js 
var Hebcal = require('hebcal');
MTVL10d09b0d4:~ mradwin$ node --version
v0.10.21
MTVL10d09b0d4:~ mradwin$ npm ls hebcal
/Users/mradwin
└── hebcal@2.1.2 

MTVL10d09b0d4:~ mradwin$ node hebcal-require.js 
^C
MTVL10d09b0d4:~ mradwin$ 
Scimonster commented 10 years ago

It happened to me once, but never after that. I don't remember the Node version i was using. Maybe try updating your Node? The stable version is 0.10.28.

~Sci

On Tue, May 13, 2014 at 11:36 PM, Michael J. Radwin < notifications@github.com> wrote:

I don't know if I'm doing something wrong here... but the npm module seems to hang after requiring the module.

Can you reproduce this behavior with my 1-liner?

MTVL10d09b0d4:~ mradwin$ cat hebcal-require.js var Hebcal = require('hebcal'); MTVL10d09b0d4:~ mradwin$ node --version v0.10.21 MTVL10d09b0d4:~ mradwin$ npm ls hebcal /Users/mradwin └── hebcal@2.1.2

MTVL10d09b0d4:~ mradwin$ node hebcal-require.js ^C MTVL10d09b0d4:~ mradwin$

— Reply to this email directly or view it on GitHubhttps://github.com/hebcal/hebcal-js/issues/12 .

mjradwin commented 10 years ago

Problem unfortunately exists on Node v0.10.28 as well (Mac OS X 10.9.2, although that shouldn't really matter).

MTVL10d09b0d4:~ mradwin$ cat hebcal-require.js 
var Hebcal = require('hebcal');
MTVL10d09b0d4:~ mradwin$ node --version
v0.10.28
MTVL10d09b0d4:~ mradwin$ node hebcal-require.js 
^C
MTVL10d09b0d4:~ mradwin$ 

I also tested with node v0.10.25 on Ubuntu 14.04 trusty, and I had the same problem.

I'd be happy to debug, but I'm too new to Node.js to be much use here. My hope is to start using the Hebcal node module and begin contributing changes back to the repo...

Scimonster commented 10 years ago

So, a couple questions here. Can you try installing hebcal@2.1.1 to see if it makes any difference?
If it still doesn't work, what was the latest version that did? (2.1.2, 2.1.1, 2.1.0, 2.0.0).

If none work, go for prerelease. You'll have to checkout hebcal/hebcal-js at the v2.2.0 tag, and npm install it. Maybe even do a global install to try out the cli.

After that, i'll add some debug points to see where it's hanging.

mjradwin commented 10 years ago

npm install hebcal@2.0.0 worked fine - no hang.

npm install hebcal@2.1.0 was the first version that hangs for me. 2.1.1 and 2.1.2 also hang for me.

Scimonster commented 10 years ago

Okay, thanks. The biggest differences between 2.0 and 2.1 are the GregYear and GregMonth constructors, and Hebcal.events. I wonder if you're having trouble with loading events.

Can you enter the Node REPL (node from command line), and run require('events') to see if it works?

I also changed some code in hdate.js. From the Hebcal JS directory, can you enter REPL, and require('./hdate')?

Also, just make sure that you have suncalc in the node_modules directory, and that it has content.

Thanks.

mjradwin commented 10 years ago

When I do require('hebcal') from within REPL, it doesn't hang. Only from the command-line.

Does any of this help?

MTVL10d09b0d4:hebcal-js mradwin$ git status
On branch master
Your branch is up-to-date with 'origin/master'.

nothing to commit, working directory clean
MTVL10d09b0d4:hebcal-js mradwin$ cat .git/config 
[core]
    repositoryformatversion = 0
    filemode = true
    bare = false
    logallrefupdates = true
    ignorecase = true
    precomposeunicode = true
[remote "origin"]
    url = git@github.com:hebcal/hebcal-js.git
    fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
    remote = origin
    merge = refs/heads/master
MTVL10d09b0d4:hebcal-js mradwin$ git log | head
commit ae4629090d72541c6a6cd5ea5acc1a22c4c24093
Author: Scimonster <tehalmightyscimonster@gmail.com>
Date:   Fri Apr 4 12:11:49 2014 +0300

    Fix small mistakes; v2.1.2.

commit 985ae7f7c77db68bd3867e647626066046f594ed
Author: Scimonster <tehalmightyscimonster@gmail.com>
Date:   Fri Apr 4 12:01:01 2014 +0300

MTVL10d09b0d4:hebcal-js mradwin$ node
> var Hebcal = require('hebcal')
undefined
> Hebcal
{ [Function: Hebcal]
  addZeman: [Function],
  cities: 
   { getCity: [Function: getCity],
     listCities: [Function: listCities],
     addCity: [Function: addCity],
     nearest: [Function: nearest] },
  range: [Function: range],
  gematriya: [Function: gematriya],
  holidays: 
   { masks: 
      { USER_EVENT: 1,
        LIGHT_CANDLES: 2,
        YOM_TOV_ENDS: 4,
        CHUL_ONLY: 8,
        IL_ONLY: 16,
        LIGHT_CANDLES_TZEIS: 32 },
     IGNORE_YEAR: -1,
     Event: 
      { [Function: Event]
        isIL: false,
        candleLighting: 18,
        havdalah: 42 } },
  parshiot: 
   [ [ 'Bereshit',
       'Bereshis',
       'בראשית' ],
     [ 'Noach', 0, 'נח' ],
     [ 'Lech-Lecha', 0, 'לך-לך' ],
     [ 'Vayera', 0, 'וירא' ],
     [ 'Chayei Sara', 0, 'חי שרה' ],
     [ 'Toldot', 'Toldos', 'תולדות' ],
     [ 'Vayetzei', 0, 'ויצא' ],
     [ 'Vayishlach', 0, 'וישלח' ],
     [ 'Vayeshev', 0, 'וישב' ],
     [ 'Miketz', 0, 'מקץ' ],
     [ 'Vayigash', 0, 'ויגש' ],
     [ 'Vayechi', 0, 'ויחי' ],
     [ 'Shemot', 'Shemos', 'שמות' ],
     [ 'Vaera', 0, 'וארא' ],
     [ 'Bo', 0, 'בא' ],
     [ 'Beshalach', 0, 'בשלח' ],
     [ 'Yitro', 'Yisro', 'יתרו' ],
     [ 'Mishpatim', 0, 'משפטים' ],
     [ 'Terumah', 0, 'תרומה' ],
     [ 'Tetzaveh', 0, 'תצוה' ],
     [ 'Ki Tisa', 'Ki Sisa', 'כי תשא' ],
     [ 'Vayakhel', 0, 'ויקהל' ],
     [ 'Pekudei', 0, 'פקודי' ],
     [ 'Vayikra', 0, 'ויקרא' ],
     [ 'Tzav', 0, 'צו' ],
     [ 'Shmini', 0, 'שמיני' ],
     [ 'Tazria', 0, 'תזריע' ],
     [ 'Metzora', 0, 'מצרע' ],
     [ 'Achrei Mot',
       'Achrei Mos',
       'אחרי מות' ],
     [ 'Kedoshim', 0, 'קדשים' ],
     [ 'Emor', 0, 'אמור' ],
     [ 'Behar', 0, 'בהר' ],
     [ 'Bechukotai',
       'Bechukosai',
       'בחקתי' ],
     [ 'Bamidbar', 0, 'במדבר' ],
     [ 'Nasso', 0, 'נשא' ],
     [ 'Beha\'alotcha',
       'Beha\'aloscha',
       'בהעלתך' ],
     [ 'Sh\'lach', 0, 'שלח לך' ],
     [ 'Korach', 0, 'קורח' ],
     [ 'Chukat', 'Chukas', 'חקת' ],
     [ 'Balak', 0, 'בלק' ],
     [ 'Pinchas', 0, 'פינחס' ],
     [ 'Matot', 'Matos', 'מטות' ],
     [ 'Masei', 0, 'מסעי' ],
     [ 'Devarim', 0, 'דברים' ],
     [ 'Vaetchanan',
       'V\'eschanan',
       'ואתחנן' ],
     [ 'Eikev', 0, 'עקב' ],
     [ 'Re\'eh', 0, 'ראה' ],
     [ 'Shoftim', 0, 'שופטים' ],
     [ 'Ki Teitzei',
       'Ki Seitzei',
       'כי תצא' ],
     [ 'Ki Tavo', 'Ki Savo', 'כי תבוא' ],
     [ 'Nitzavim', 0, 'נצבים' ],
     [ 'Vayeilech', 0, 'וילך' ],
     [ 'Ha\'Azinu', 0, 'האזינו' ] ],
  LANGUAGE: [Function: LANGUAGE],
  map: [Function: map],
  filter: [Function: filter],
  defaultLocation: [Getter/Setter],
  defaultCity: [Getter/Setter],
  candleLighting: [Getter/Setter],
  havdalah: [Getter/Setter],
  Month: [Function: Month],
  HDate: 
   { [Function: HDate]
     defaultLocation: [ 0, 0 ],
     defaultCity: [Getter/Setter],
     addZeman: [Function] },
  events: 
   { domain: null,
     _events: {},
     _maxListeners: 10,
     refreshInterval: [Getter/Setter],
     beforeZeman: 600000,
     customs: {} },
  GregYear: [Function: GregYearConstructor],
  GregMonth: [Function: GregMonth] }
> MTVL10d09b0d4:hebcal-js mradwin$ node
> require('events')
{ usingDomains: false,
  EventEmitter: { [Function: EventEmitter] listenerCount: [Function] } }
> MTVL10d09b0d4:hebcal-js mradwin$ node
> require('./hdate')
{ [Function: HDate]
  defaultLocation: [ 0, 0 ],
  defaultCity: [Getter/Setter],
  addZeman: [Function] }
> MTVL10d09b0d4:hebcal-js mradwin$ ls node_modules/suncalc/
LICENSE     package.json    suncalc.js
README.md   sample.js   test.js
MTVL10d09b0d4:hebcal-js mradwin$ cp ~/hebcal-require.js .
MTVL10d09b0d4:hebcal-js mradwin$ cat hebcal-require.js 
var Hebcal = require('hebcal');
MTVL10d09b0d4:hebcal-js mradwin$ node hebcal-require.js 
^C
MTVL10d09b0d4:hebcal-js mradwin$ 
Scimonster commented 10 years ago

Very interesting that it works from REPL but not CLI.

Try running the following:

require.resolve('hebcal') // in REPL
console.log(require.resolve('hebcal')) // in file

I wonder if it's not finding the module correctly.

mjradwin commented 8 years ago

I've been trying to use this package again (I'm playing with an AWS Lambda function for integrating Hebcal as an Alexa Skills Kit) and would find it more convenient to use JavaScript than shelling out to the C executable. I've narrowed down the cause of the hang to hebcal.js:763

Here's the line of code that causes the problem:

    events.refreshInterval = 1000 * 60 * 5; // 5 minutes

This sets a timer using setInterval() that never gets cleared, so Node keeps running the code forever.