Skip to content

RetrieveAll() erroring without specifying cause #26

Description

@selfagency

Here's what I've got:

import consola from 'consola'
import { extract, LetterparserMail } from 'letterparser'
import { Client, YapopleClientConfig } from 'yapople'

const emailService = async (): Promise<LetterparserMail[]> => {
  try {
    const messageList: LetterparserMail[] = []

    if (process.env.EMAIL_ADDRESS && process.env.EMAIL_PASSWORD && process.env.EMAIL_HOST) {
      const clientConfig: YapopleClientConfig = {
        host: process.env.EMAIL_HOST,
        port: 995,
        tls: true,
        mailparser: false,
        username: process.env.EMAIL_ADDRESS,
        password: process.env.EMAIL_PASSWORD
      }
      const client = new Client(clientConfig)

      consola.log(`Connecting to ${process.env.EMAIL_HOST}`)
      await client.connect()

      const count = await client.count()
      consola.log(`${count} messages found on server`)

      try {
        const msgs = await client.retrieveAll()
        msgs.forEach(msg => messageList.push(extract(msg.toString())))
      } catch (err) {
        consola.log(`Error retrieving messages from server: ${err}`)
      }
      consola.log(`Messages parsed: ${messageList.length}`)

      await client.quit()
    } else {
      consola.error('EMAIL_ADDRESS, EMAIL_PASSWORD, and EMAIL_HOST environment variables are required')
    }

    return messageList
  } catch (error) {
    consola.error(error)
    throw error
  }
}

export default emailService

And here's what's happening:

Connecting to imap.migadu.com                                                                 14:20:47
285 messages found on server                                                                  14:20:47
                                         												      14:20:53
After all, it takes a lot of emotional energy to curate the best
AWS news for you every week. If you think your AWS bill is high,
you should see my therapy invoices.

Living my truth,

Corey

P.S. Here=E2=80=99s a hot tip for keeping yourself comfy at re:Invent (
https://click.lastweekinaws.com/d0uvkvx9rdamu0m345im/9qhzhdul6698w0c9/aHR0c=
HM6Ly93d3cubGFzdHdlZWtpbmF3cy5jb20vYmxvZy9pbS1hbi1hd3MtY2VydGlmaWVkLWNsb3Vk=
LXByYWN0aXRpb25lci8=3D
). Don=E2=80=99t say it came from me.

What'd you think of this email?

=F0=9F=91=8E (
https://click.lastweekinaws.com/d0uvkvx9rdamu0m345im/e0h97qlxi0unx3z2gwh8/a=
HR0cHM6Ly93d3cubGFzdHdlZWtpbmF3cy5jb20vc3BlY2lhbC90aHVtYnNkb3duLw=3D=3D
)
=F0=9F=91=8D (
https://click.lastweekinaws.com/d0uvkvx9rdamu0m345im/8ghrwvprt3u5468xvxtk/a=
HR0cHM6Ly93d3cubGFzdHdlZWtpbmF3cy5jb20vc3BlY2lhbC90aHVtYnN1cC8=3D
)

---------------
I=E2=80=99m Corey Quinn
---------------

  I help companies address their horrifying AWS bills
  by both reducing the dollars spent and help
  at Client.onData (node_modules/yapople/lib/yapople.js:108:19)
  at TLSSocket.emit (events.js:375:28)
  at addChunk (internal/streams/readable.js:290:12)
  at readableAddChunk (internal/streams/readable.js:265:9)
  at TLSSocket.Readable.push (internal/streams/readable.js:204:10)
  at TLSWrap.onStreamRead (internal/stream_base_commons.js:188:23)


Messages parsed: 0     																	      14:20:53

events.js:352
      throw er; // Unhandled 'error' event
      ^

Error
Emitted 'error' event on TLSSocket instance at:
    at TLSSocket._emitTLSError (_tls_wrap.js:892:10)
    at TLSWrap.onerror (_tls_wrap.js:416:11)

Once it gets there, it just hangs and never proceeds. As you can see, I've disabled parsing in your library, so that shouldn't be the cause. I'm running Node 14 LTS.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions