question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Issues with receiving data from callMain

See original GitHub issue

Issuehunt badges

Hello, I’ve run into this issue over the past week that I’ve been unable to move beyond, and I would appreciate another pair of eyes.

In my renderer, I have 2 separate pieces of code that use callMain to get a response back from the main process. One of them returns data just fine, the other returns nothing at all, despite logging showing that the main listener receives it and returns successfully. I even used devtron to see that a message is getting sent to the renderer, but for some reason the listener is not working as expected.

I wonder if I am just fundamentally misinterpreting the library, or if there is something causing my second call to fail. Any thoughts would be appreciated. Main and rendering code is shown below:

renderer.js

// this function works fine
function* checkExistingUser() {
  console.log('checking existing user.');
  const resp = yield ipc.callMain('check-existing-user', 'TESTUSER');
  if (resp.error) {
    console.error('Received error from ipc main');
    return;
  }
  // other behavior
}

// this function doesn't return data from callMain
function* unlockUserCredentials(action) {
  let localUserData = yield select(getLocalData);
  // code makes it here, logging shows up
  try {
    const resp = yield ipc.callMain('unlock-user-credentials', credData);
    console.log(resp); // never shows up in logs
  } catch (error) {
    console.log(error); // never shows up in logs
  }
}

My main file:

// this function responds fine, and data is accessible on the client
ipc.answerRenderer('check-existing-user', async data => {
  // working returns
  return {};
});

// this function returns successfully, even with try catch
ipc.answerRenderer('unlock-user-credentials', async data => {
  return {
    message: 'sample data',
  };
});

am I doing something wrong by having multiple ipc answer renderers here? Any thoughts or ideas are appreciated. As a note, my renderer code is written for use with redux-saga.


IssueHunt Summary

garrylachman garrylachman has been rewarded.

Backers (Total: $60.00)

Submitted pull Requests


Tips


IssueHunt has been backed by the following sponsors. Become a sponsor

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:10 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
garrylachmancommented, Jul 13, 2019
1reaction
issuehunt-app[bot]commented, Aug 14, 2019

@sindresorhus has rewarded $54.00 to @garrylachman. See it on IssueHunt

  • 💰 Total deposit: $60.00
  • 🎉 Repository reward(0%): $0.00
  • 🔧 Service fee(10%): $6.00
Read more comments on GitHub >

github_iconTop Results From Across the Web

A General Overview of What Happens Before main()
Depending on the program and the compiler, there are all kinds of interesting functions that get run before main , automatically inserted by ......
Read more >
java - Problem receiving data through Intent on Android
Generally speaking, do not call Activity methods from a field initializer. Move your getIntent() and getExtras() calls to be inside of ...
Read more >
Is it safe to call main() from anywhere? | AVR Freaks
I'm receiving UART in an interrupt vector. ... I am not getting what is going on here. Assuming that the problem feared is...
Read more >
Using a proxy with S3 storage cause cluster become...
Symptoms and tests to confirm The entire cluster becomes unstable with the Cluster Master showing flapping of indexers from up to down.
Read more >
Solved Write the code for both problems in functions below | Chegg ...
Getting data from the user and printing the results should be done in main. When completed, the main function should get input data...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found