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.

Better multi/exec results (suggestion)?

See original GitHub issue

Hello.

As for versions 1.x and 2.x-rc transaction multi/exec results are returned in [Error, [Error1, Value1], ... ] format. With promised based API it looks very confusing, for example:

ioredis.multi().get('key1').get('key2').exec()
  .spread( ([e1, val1], [e2, val2]) => {
    /* NO ERRORS(?) */
  })
  .catch(e => {
    /* ERROR HANDLING */
  });

It is unclear what should e1 and e2 mean in this context. As far as i understand, partially applied transaction should happen only when arguments count is wrong, or command is used on a wrong value type. So such errors should never occur when redis is used correctly. Will it be better to have something like this?

ioredis.multi().get('key1').get('key2').exec()
  .spread( (val1, val2) => {
    /* NO ERRORS */
  })
  .catch(e => {
    /* ERROR HANDLING, e may have a field with transaction results
     * like this [ [Error1, Value1], ... ] */
  });

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
stale[bot]commented, Oct 23, 2017

This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 7 days if no further activity occurs, but feel free to re-open a closed issue if needed.

0reactions
lo1tumacommented, Aug 17, 2016

I would also like to see a better transaction result format for the promise-based API.

What do you think about introducing a custom error type, e.g. PartiallyAppliedTransactionError which could have additional fields that point exactly to the commands that have been applied or failed, for example:

redis.multi().set('key1', 'val1').hget('key1', 'val1').exec()
    .catch(error => {
        if (error instanceof redis.PartiallyAppliedTransactionError) {
            console.log(error.commandErrors); // ⇨ [null, [ReplyError: WRONGTYPE Operation against a key holding the wrong kind of value]]
            console.log(error.commandResults); // ⇨ ['OK', null]
        }
    });
Read more comments on GitHub >

github_iconTop Results From Across the Web

Which Redis commands make sense inside of Multi - Exec?
I'm writing a PHP 5 wrapper class to the Owlient PhpRedis PHP C extension, because, for example some commands in my application record...
Read more >
Interleaving Watch Multi/exec on a single Redis connection ...
To answer my own question: This is expected behavior. The first exec unwatches all properties. Therefore, the second multi/exec goes through without ...
Read more >
Feedback - WinSSHTerm
I have been trying WinSSHterm for awhile and it's a good product. I like to know if you can add few more updates...
Read more >
Pipelines — redis-py-cluster 2.1.3 documentation
Suggestion two¶ ... Current pipeline implementation. This implementation is rather good and works well because it combines the existing pipeline interface and ...
Read more >
curl_multi_exec - Manual - PHP
Solve CPU 100% usage, a more simple and right way: <?php ... run curl multi exec in background while fiber is in suspend...
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