Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8789275
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T22:21:37+00:00 2026-06-13T22:21:37+00:00

I try to rewire my brain for async coding and I still I still

  • 0

I try to rewire my brain for async coding and I still I still seem to fail. Unfortunately I can’t figure out how to do it properly in this case. Let me give an example:

var nconf = require('nconf');

 nconf.argv()
 .env();

 function runme(callback){
   var nummessages = nconf.get('SMS_MESSAGES');
   decodemessage(0, nummessages);
   callback();
 }

 function decodemessage(i, nummessages) {
  if( i < nummessages ) {
    var message = 'SMS_'+(i+1)+'_TEXT';
    var number = 'SMS_'+(i+1)+'_NUMBER';
    console.log('number: '+number);
    console.log('message: '+message);
    console.log('message text: '+ nconf.get(message));
    console.log('message number: '+ nconf.get(number));
    decodemessage(i+1);
  }
} 

runme(function(){
  process.exit(0);
});

This gets called by gammu-smsd which receives SMS messages and puts them into ENV vars and launches a script. This works fine as long as I run it on my own, return code seems to work as well. When I run it from gammu-smsd it fails and it looks like decodemessage is never executed. Some debug output shows that I do go into runme().

My guess is that the callback in runme() gets executed before the recursive decodemessage() call is done. Am I right and if so can someone explain how I can do that properly?

If you want to test run it like this:

node server.js --SMS_MESSAGES 2 --SMS_1_TEXT blabliblo --SMS_1_NUMBER=47796546546 --SMS_2_TEXT Iammessagetwo --SMS_2_NUMBER 12345678

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T22:21:38+00:00Added an answer on June 13, 2026 at 10:21 pm

    Seems like you forgot to pass on the nummessages in your recursive call:

    decodemessage(i+1, nummessages);
    

    That’s why I personally mostly loop backwards (to zero) when using recursion.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Try this out: template <typename T> class Base { public: int someBaseMember; }; template
Try this code - import java.io.StringReader; public class StringReaderTest { public static void main(String[]
Try this piece of code - public class WhitespaceTest { public static void main(String[]
try: recursive_function() except RuntimeError e: # is this a max. recursion depth exceeded exception?
Try to see which cast is faster (not necessary better): new c++ case or
try { FileOutputStream out = new FileOutputStream(p1); pictureTaken.compress(Bitmap.CompressFormat.PNG, 90, out); out.close(); } catch (Exception
Try as I might, I cannot get this to work. Here is my latest
Try this: Make a new XCode4 Applescript project. In the delegate, paste this code:
Try this: <div style=float:left><p>LEFT</p></div> <div style=float:right><p>RIGHT</p></div> <div><p> <input type=text style=width:100% /> <input type=submit />
Try this showcase: <!doctype html> <html> <head> <style> html { min-height: 100%; overflow-y: scroll;

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.