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.

Synchronous vs Asynchronous

See original GitHub issue

Synchronous

var jwt = require('jsonwebtoken');
var token = jwt.sign({ foo: 'bar' }, 'shhhhh');

Asynchronous

var token = jwt.sign({ foo: 'bar' }, 'shhhhh', function(err, token) {
  console.log(token);
);

I want to know , is it bad to use Synchronous way , in express js server? is there any benefit with Asynchronous mode? As I think there is no I/O and just CPU usage, So Asynchronous and Synchronous must b same, just syntax is different

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:14
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

45reactions
ziluvatarcommented, Feb 15, 2019

TL;DR; To allow consumers load keys from filesystem or any other source of ReadStream without blocking event loop. Not to actually perform the signing.

I’ve been digging into git history and jws implementation to understand why the library provided the async functionality for signing:

Honestly, not sure if that streaming is a desired feature by consumers, we’d need to update the README to make it clear.

9reactions
lonix1commented, Feb 11, 2019

If there is no perf difference, why does the library offer an async alternative?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Asynchronous vs. Synchronous Programming - Mendix
Asynchronous is a non-blocking architecture, so the execution of one task isn't dependent on another. Tasks can run simultaneously. Synchronous ...
Read more >
Synchronous Vs. Asynchronous Classes - TheBestSchools.org
Synchronous classes run in real time, with students and instructors attending together from different locations. Asynchronous classes run on ...
Read more >
Synchronous vs. Asynchronous Learning - Ohio State Online
On the other hand, synchronous online learning means that students are required to log in and participate in class at a specific time...
Read more >
Asynchronous vs synchronous execution. What is the ...
Synchronous basically means that you can only execute one thing at a time. Asynchronous means that you can execute multiple things ...
Read more >
Difference synchronous vs asynchronous learning - Easy LMS
If synchronous learning takes place at the same time, asynchronous learning refers to the opposite. The instructor, the learner, and other ...
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