no-restricted-syntax on for await blocking all async iterables [javascript] - TagMerge

no-restricted-syntax on for await blocking all async iterables [javascript]

horvaticAsked 5 months ago

I am currently working with a async iterables, but I am unable to iterate over it as for await is blocked.

Code example:

export async function* iteratorMessages() {
  const data = await queue.receiveMessage(params).promise().catch((err) => {
  if(!data || !data.Messages) {
  yield data.Messages[0];
  const results = [];
  for await (const message of iteratorMessages()) {
    results.push(processMessage(message.Body, message.ReceiptHandle));
  await Promise.all(results)

What is the replacement of for await if any? Was for await and async iterables blocked for a reason? What is the preferred way of making these calls?

Source: link

ljharbAnswered 5 months ago

There is no replacement for it; as written, the guide does not allow usage of async iterables.

There's a proposal which would allow async iterables to be consumed without a loop (thus, without regenerator-runtime), but until then, an eslint override is necessary.

Recent Issues

    Programming Languages