Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Next Api endpoints are not updated and also throws an Cloudflare worker exception 1101 #252

Closed
Rashmi-278 opened this issue Sep 25, 2020 · 12 comments

Comments

@Rashmi-278
Copy link

After making the changes to the api file located in directory /pages/api
I recreated the fab.zip file and deployed to Cloudflare workers
The api endpoint still returns the previous json object

the api endpoint is https://nextdemo2.rashmi-va.workers.dev/api/hello
server scripted api endpoint https://nextdemo2.rashmi-va.workers.dev/hey

The changes I made in file was to the name value
#####Before

export default (req, res) => {
  res.statusCode = 200
  res.json({ name: 'John Do 1 ' })
}

#####After

export default (req, res) => {
  res.statusCode = 200
  res.json({ name: 'John Doe 2 ' })
}

But we still receive "John Do 1"
This behaviour is observed with index file too , previously the index file contained some errors , upon rectifying them and updating the file. The previous version of index.js file is served.

The server side scripted API enpoints are updated as expected.

@Rashmi-278
Copy link
Author

@evanderkoogh
This is as discussed on discord in cloudflare-workers channel

@Rashmi-278
Copy link
Author

Update : Building with --skip-cache flag successfully updates all the files including API files.
But the Cloudflare workers exception 1101 is still thrown upon refreshing the API endpoint

@geelen
Copy link
Contributor

geelen commented Oct 19, 2020

Ok, I've deployed an instance of the NextJS test we use in the E2E test suite and can reproduce the problem:

{
    outcome: 'exception',
    scriptName: null,
    exceptions: [
      {
        name: 'Error',
        message: 'The script will never generate a response.',
        timestamp: 1603124585425,
      },
    ],
    logs: [{ message: [{ renderer: {} }], level: 'log', timestamp: 1603124585425 }],
    eventTimestamp: 1603124585425,
    event: {
      request: {
        url: 'https://nextjs-api-no-bueno.glen.workers.dev/api/time',
        method: 'GET',
        headers: {
          accept: 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
          'accept-encoding': 'gzip',
          'accept-language': 'en-AU,en;q=0.7,en-US;q=0.3',
          'cache-control': 'max-age=0',
          'cf-connecting-ip': '81.100.172.220',
          'cf-ipcountry': 'GB',
          'cf-ray': '5e4bd772dd9bf3ff',
          'cf-request-id': '05e344fbca0000f3ffa5162000000001',
          'cf-visitor': '{"scheme":"https"}',
          connection: 'Keep-Alive',
          cookie: 'REDACTED',
          dnt: '1',
          host: 'nextjs-api-no-bueno.glen.workers.dev',
          'upgrade-insecure-requests': '1',
          'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:81.0) Gecko/20100101 Firefox/81.0',
          'x-forwarded-proto': 'https',
          'x-real-ip': '81.100.172.220',
        },
        cf: {
          tlsExportedAuthenticator: {
            clientFinished: '095e683b06fec9db068cfc479bf935ccf4b32013f13f48432c5192782208cce3',
            clientHandshake: 'fa7567448054963f12b0de9f64fc46cf0520bc30078e84351d59ee0d3bb35672',
            serverHandshake: '1b8fa4d7376e38edebc714e0a0517be27db2a56357150034e291b4c654bf8fdd',
            serverFinished: 'a3b4c79bcfb8bbb68a1a94c7f84f234c581e5897ecb0bac8b662e44f646926ed',
          },
          tlsVersion: 'TLSv1.3',
          httpProtocol: 'HTTP/2',
          tlsCipher: 'AEAD-AES128-GCM-SHA256',
          edgeRequestKeepAliveStatus: 1,
          requestPriority: 'weight=42;exclusive=0;group=13;group-weight=241',
          country: 'GB',
          clientAcceptEncoding: 'gzip, deflate, br',
          clientTcpRtt: 19,
          colo: 'LHR',
          tlsClientAuth: {
            certIssuerDNLegacy: '',
            certIssuerDN: '',
            certIssuerDNRFC2253: '',
            certSubjectDNLegacy: '',
            certVerified: 'NONE',
            certNotAfter: '',
            certSubjectDN: '',
            certFingerprintSHA1: '',
            certNotBefore: '',
            certSerial: '',
            certPresented: '0',
            certSubjectDNRFC2253: '',
          },
          asn: 5089,
        },
      },
    },
  },

That's the error. Running it the first time I get an OK response, as you've observed:

{
    outcome: 'ok',
    scriptName: null,
    exceptions: [],
    logs: [],
    eventTimestamp: 1603124560012,
    event: {
      request: {
        url: 'https://nextjs-api-no-bueno.glen.workers.dev/_next/static/chunks/framework.964e76377795026233d5.js',
        method: 'GET',
        headers: {
          accept: '*/*',
          'accept-encoding': 'gzip',
          'accept-language': 'en-AU,en;q=0.7,en-US;q=0.3',
          'cf-connecting-ip': '81.100.172.220',
          'cf-ipcountry': 'GB',
          'cf-ray': '5e4bd6d3ead7f3ff',
          'cf-request-id': '05e34498710000f3ffa533b000000001',
          'cf-visitor': '{"scheme":"https"}',
          connection: 'Keep-Alive',
          cookie: 'REDACTED',
          dnt: '1',
          host: 'nextjs-api-no-bueno.glen.workers.dev',
          referer: 'https://nextjs-api-no-bueno.glen.workers.dev/',
          'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:81.0) Gecko/20100101 Firefox/81.0',
          'x-forwarded-proto': 'https',
          'x-real-ip': '81.100.172.220',
        },
        cf: {
          tlsExportedAuthenticator: {
            clientFinished: '095e683b06fec9db068cfc479bf935ccf4b32013f13f48432c5192782208cce3',
            clientHandshake: 'fa7567448054963f12b0de9f64fc46cf0520bc30078e84351d59ee0d3bb35672',
            serverHandshake: '1b8fa4d7376e38edebc714e0a0517be27db2a56357150034e291b4c654bf8fdd',
            serverFinished: 'a3b4c79bcfb8bbb68a1a94c7f84f234c581e5897ecb0bac8b662e44f646926ed',
          },
          tlsVersion: 'TLSv1.3',
          httpProtocol: 'HTTP/2',
          tlsCipher: 'AEAD-AES128-GCM-SHA256',
          edgeRequestKeepAliveStatus: 1,
          requestPriority: 'weight=22;exclusive=0;group=7;group-weight=1',
          country: 'GB',
          clientAcceptEncoding: 'gzip, deflate, br',
          clientTcpRtt: 22,
          colo: 'LHR',
          tlsClientAuth: {
            certIssuerDNLegacy: '',
            certIssuerDN: '',
            certIssuerDNRFC2253: '',
            certSubjectDNLegacy: '',
            certVerified: 'NONE',
            certNotAfter: '',
            certSubjectDN: '',
            certFingerprintSHA1: '',
            certNotBefore: '',
            certSerial: '',
            certPresented: '0',
            certSubjectDNRFC2253: '',
          },
          asn: 5089,
        },
      },
    },
  },

I can't really see what might be causing it. But opening a new private window, the first request works and the subsequent ones don't. Running curl https://nextjs-api-no-bueno.glen.workers.dev/api/time several times doesn't cause the error, so I'm very confused. Here's the wrangler logs for two cURL invocations:

{
    outcome: 'ok',
    scriptName: null,
    exceptions: [],
    logs: [{ message: [{ renderer: {} }], level: 'log', timestamp: 1603124789179 }],
    eventTimestamp: 1603124789179,
    event: {
      request: {
        url: 'https://nextjs-api-no-bueno.glen.workers.dev/api/time',
        method: 'GET',
        headers: {
          accept: '*/*',
          'accept-encoding': 'gzip',
          'cf-connecting-ip': '81.100.172.220',
          'cf-ipcountry': 'GB',
          'cf-ray': '5e4bdc69dc590792',
          'cf-request-id': '05e3481627000007924f115000000001',
          'cf-visitor': '{"scheme":"https"}',
          connection: 'Keep-Alive',
          host: 'nextjs-api-no-bueno.glen.workers.dev',
          'user-agent': 'curl/7.68.0',
          'x-forwarded-proto': 'https',
          'x-real-ip': '81.100.172.220',
        },
        cf: {
          tlsExportedAuthenticator: {
            clientFinished: '3b05a18bfc7a1e9b963176f509a65460888fcb87871c7b29e1ca17b51c2886a1e7cb403be677aed6e58373a02ece0e99',
            clientHandshake: '2bd9326355d2dc48bb243d7d3bdf4824394f1a391c58bfa385ef74edd57b4ec6eff54318a9ac752522efa3984471b59c',
            serverHandshake: 'e42a2c94401888a086bbe932ac2d08534e523e923c0ee64a37d4e9fc5a6ba7d6120708bcd1a12bb92d3df4a33f0a8b85',
            serverFinished: '99f1a4531b0364d0b97a155bf934c35f61cf174cb48e5c76c1afb8101bd26d9ea637a9227e7ee14c3a9b5efcb131b2a0',
          },
          tlsVersion: 'TLSv1.3',
          httpProtocol: 'HTTP/2',
          tlsCipher: 'AEAD-AES256-GCM-SHA384',
          edgeRequestKeepAliveStatus: 1,
          requestPriority: 'weight=16;exclusive=0;group=0;group-weight=0',
          country: 'GB',
          clientTcpRtt: 15,
          colo: 'LHR',
          tlsClientAuth: {
            certIssuerDNLegacy: '',
            certIssuerDN: '',
            certIssuerDNRFC2253: '',
            certSubjectDNLegacy: '',
            certVerified: 'NONE',
            certNotAfter: '',
            certSubjectDN: '',
            certFingerprintSHA1: '',
            certNotBefore: '',
            certSerial: '',
            certPresented: '0',
            certSubjectDNRFC2253: '',
          },
          asn: 5089,
        },
      },
    },
  }
{
    outcome: 'ok',
    scriptName: null,
    exceptions: [],
    logs: [{ message: [{ renderer: {} }], level: 'log', timestamp: 1603124786685 }],
    eventTimestamp: 1603124786685,
    event: {
      request: {
        url: 'https://nextjs-api-no-bueno.glen.workers.dev/api/time',
        method: 'GET',
        headers: {
          accept: '*/*',
          'accept-encoding': 'gzip',
          'cf-connecting-ip': '81.100.172.220',
          'cf-ipcountry': 'GB',
          'cf-ray': '5e4bdc5a0e1ce684',
          'cf-request-id': '05e3480c420000e68432116000000001',
          'cf-visitor': '{"scheme":"https"}',
          connection: 'Keep-Alive',
          host: 'nextjs-api-no-bueno.glen.workers.dev',
          'user-agent': 'curl/7.68.0',
          'x-forwarded-proto': 'https',
          'x-real-ip': '81.100.172.220',
        },
        cf: {
          tlsExportedAuthenticator: {
            clientFinished: 'b6e266a1b814d215b18e7b220200033d31e41dacfc0d2c2544a99882ee50b33817b40b3f9d46b93c25fc9c6c5c7101a2',
            clientHandshake: 'a0dc52000c48cc092cf5df698243c0e35693c60c036f35bf881bffa87f235a1e189f5b813cfbf8ab574b753ca406f615',
            serverHandshake: '813c348b7b13dd7a52759dfa014b19f1432aae7d99e4be5323783f69a020c2ef95e94203430a2f3f94372941393fc501',
            serverFinished: 'd96878b472d77177b44064fbc202d9b50dbce90226953275a1a21224676abb1d266b0b7cc10266afa905487b547b9be5',
          },
          tlsVersion: 'TLSv1.3',
          httpProtocol: 'HTTP/2',
          tlsCipher: 'AEAD-AES256-GCM-SHA384',
          edgeRequestKeepAliveStatus: 1,
          requestPriority: 'weight=16;exclusive=0;group=0;group-weight=0',
          country: 'GB',
          clientTcpRtt: 16,
          colo: 'LHR',
          tlsClientAuth: {
            certIssuerDNLegacy: '',
            certIssuerDN: '',
            certIssuerDNRFC2253: '',
            certSubjectDNLegacy: '',
            certVerified: 'NONE',
            certNotAfter: '',
            certSubjectDN: '',
            certFingerprintSHA1: '',
            certNotBefore: '',
            certSerial: '',
            certPresented: '0',
            certSubjectDNRFC2253: '',
          },
          asn: 5089,
        },
      },
    },
  }

Going to drop some logging in and see what the hell is going on, just wanted to dump these logs here in case someone else can see what the issue is.

@geelen
Copy link
Contributor

geelen commented Oct 19, 2020

Added logs every line of api/time.js. When it fails we don't hit any, it's not even being entered...

[
    {
      outcome: 'ok',
      scriptName: null,
      exceptions: [],
      logs: [
        { message: [{ renderer: {} }], level: 'log', timestamp: 1603125283530 },
        { message: ['I AM HERE'], level: 'log', timestamp: 1603125283530 },
        { message: ['NOW HERE'], level: 'log', timestamp: 1603125283530 },
        { message: ['OH LORD'], level: 'log', timestamp: 1603125283530 },
        { message: ['I HERE'], level: 'log', timestamp: 1603125283530 },
        { message: ['OMAR COMIN'], level: 'log', timestamp: 1603125283530 },
        { message: ['HOO BOY'], level: 'log', timestamp: 1603125283530 },
        { message: ['WE DUN'], level: 'log', timestamp: 1603125283530 },
      ],
      eventTimestamp: 1603125283530,
      event: {
        request: {
          url: 'https://nextjs-api-no-bueno.glen.workers.dev/api/time',
          method: 'GET',
          headers: {
            accept: 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
            'accept-encoding': 'gzip',
            'accept-language': 'en-AU,en;q=0.7,en-US;q=0.3',
            'cache-control': 'max-age=0',
            'cf-connecting-ip': '81.100.172.220',
            'cf-ipcountry': 'GB',
            'cf-ray': '5e4be87bab7106e5',
            'cf-request-id': '05e34fa147000006e56a22a000000001',
            'cf-visitor': '{"scheme":"https"}',
            connection: 'Keep-Alive',
            cookie: 'REDACTED',
            dnt: '1',
            host: 'nextjs-api-no-bueno.glen.workers.dev',
            'upgrade-insecure-requests': '1',
            'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:81.0) Gecko/20100101 Firefox/81.0',
            'x-forwarded-proto': 'https',
            'x-real-ip': '81.100.172.220',
          },
          cf: {
            tlsExportedAuthenticator: {
              clientFinished: '8a4bcc357793bcba695bbf45603dcb0ac8a57063afb45accf72fc83d0d230e75',
              clientHandshake: 'e0cb4aec07dc74422b1b05c5c62944429e2122a658ac3fc4142fd185664b4ff1',
              serverHandshake: 'e69092179b0670588ee93b33f3626f043ad502394d91b392b36ce9190dc59489',
              serverFinished: 'd640f268797987fce323031fc3a5ec2a92968b2459cc2ecf36d1695873893c48',
            },
            tlsVersion: 'TLSv1.3',
            httpProtocol: 'HTTP/2',
            tlsCipher: 'AEAD-AES128-GCM-SHA256',
            edgeRequestKeepAliveStatus: 1,
            requestPriority: 'weight=42;exclusive=0;group=13;group-weight=241',
            country: 'GB',
            clientAcceptEncoding: 'gzip, deflate, br',
            clientTcpRtt: 15,
            colo: 'LHR',
            tlsClientAuth: {
              certIssuerDNLegacy: '',
              certIssuerDN: '',
              certIssuerDNRFC2253: '',
              certSubjectDNLegacy: '',
              certVerified: 'NONE',
              certNotAfter: '',
              certSubjectDN: '',
              certFingerprintSHA1: '',
              certNotBefore: '',
              certSerial: '',
              certPresented: '0',
              certSubjectDNRFC2253: '',
            },
            asn: 5089,
          },
        },
      },
    },
    {
      outcome: 'exception',
      scriptName: null,
      exceptions: [
        {
          name: 'Error',
          message: 'The script will never generate a response.',
          timestamp: 1603125284664,
        },
      ],
      logs: [{ message: [{ renderer: {} }], level: 'log', timestamp: 1603125284664 }],
      eventTimestamp: 1603125284664,
      event: {
        request: {
          url: 'https://nextjs-api-no-bueno.glen.workers.dev/api/time',
          method: 'GET',
          headers: {
            accept: 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
            'accept-encoding': 'gzip',
            'accept-language': 'en-AU,en;q=0.7,en-US;q=0.3',
            'cache-control': 'max-age=0',
            'cf-connecting-ip': '81.100.172.220',
            'cf-ipcountry': 'GB',
            'cf-ray': '5e4be8852eed06e5',
            'cf-request-id': '05e34fa735000006e51f008000000001',
            'cf-visitor': '{"scheme":"https"}',
            connection: 'Keep-Alive',
            cookie: 'REDACTED',
            dnt: '1',
            host: 'nextjs-api-no-bueno.glen.workers.dev',
            'upgrade-insecure-requests': '1',
            'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:81.0) Gecko/20100101 Firefox/81.0',
            'x-forwarded-proto': 'https',
            'x-real-ip': '81.100.172.220',
          },
          cf: {
            tlsExportedAuthenticator: {
              clientFinished: '8a4bcc357793bcba695bbf45603dcb0ac8a57063afb45accf72fc83d0d230e75',
              clientHandshake: 'e0cb4aec07dc74422b1b05c5c62944429e2122a658ac3fc4142fd185664b4ff1',
              serverHandshake: 'e69092179b0670588ee93b33f3626f043ad502394d91b392b36ce9190dc59489',
              serverFinished: 'd640f268797987fce323031fc3a5ec2a92968b2459cc2ecf36d1695873893c48',
            },
            tlsVersion: 'TLSv1.3',
            httpProtocol: 'HTTP/2',
            tlsCipher: 'AEAD-AES128-GCM-SHA256',
            edgeRequestKeepAliveStatus: 1,
            requestPriority: 'weight=42;exclusive=0;group=13;group-weight=241',
            country: 'GB',
            clientAcceptEncoding: 'gzip, deflate, br',
            clientTcpRtt: 16,
            colo: 'LHR',
            tlsClientAuth: {
              certIssuerDNLegacy: '',
              certIssuerDN: '',
              certIssuerDNRFC2253: '',
              certSubjectDNLegacy: '',
              certVerified: 'NONE',
              certNotAfter: '',
              certSubjectDN: '',
              certFingerprintSHA1: '',
              certNotBefore: '',
              certSerial: '',
              certPresented: '0',
              certSubjectDNRFC2253: '',
            },
            asn: 5089,
          },
        },
      },
    },
  ]

@geelen
Copy link
Contributor

geelen commented Oct 19, 2020

Wow, ok, so our renderer still looks ok from the outside:

image

    {
      outcome: 'exception',
      scriptName: null,
      exceptions: [
        {
          name: 'Error',
          message: 'The script will never generate a response.',
          timestamp: 1603125684232,
        },
      ],
      logs: [
        { message: [{ renderer: {} }], level: 'log', timestamp: 1603125684232 },
        { message: ['WE A DEFAULT FUNCTION'], level: 'log', timestamp: 1603125684232 },
      ],
      eventTimestamp: 1603125684232,
      event: {
        request: {
          url: 'https://nextjs-api-no-bueno.glen.workers.dev/api/time',
          method: 'GET',
          headers: {
            accept: 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
            'accept-encoding': 'gzip',
            'accept-language': 'en-AU,en;q=0.7,en-US;q=0.3',
            'cache-control': 'max-age=0',
            'cf-connecting-ip': '81.100.172.220',
            'cf-ipcountry': 'GB',
            'cf-ray': '5e4bf24668482c66',
            'cf-request-id': '05e355c00200002c665da29000000001',
            'cf-visitor': '{"scheme":"https"}',
            connection: 'Keep-Alive',
            cookie: 'REDACTED',
            dnt: '1',
            host: 'nextjs-api-no-bueno.glen.workers.dev',
            'upgrade-insecure-requests': '1',
            'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:81.0) Gecko/20100101 Firefox/81.0',
            'x-forwarded-proto': 'https',
            'x-real-ip': '81.100.172.220',
          },
          cf: {
            tlsExportedAuthenticator: {
              clientFinished: '156c9a4f85b9afe767f13ec4d4ec60fe437eb36a7c9e475aaeb12872cf5a5cee',
              clientHandshake: 'ab75e056d986636a64904c166fd4cc45937da40adfd5474b3bb79357a0b8a8dc',
              serverHandshake: '86434c0b2606ada19c82d88ef8a90046cea32f8f14ef6b6b38905a1603832bd5',
              serverFinished: 'dac4468ea0fc787b97db6bdef45016886e02b74572c9918249408fcea1e53c48',
            },
            tlsVersion: 'TLSv1.3',
            httpProtocol: 'HTTP/2',
            tlsCipher: 'AEAD-AES128-GCM-SHA256',
            edgeRequestKeepAliveStatus: 1,
            requestPriority: 'weight=42;exclusive=0;group=13;group-weight=241',
            country: 'GB',
            clientAcceptEncoding: 'gzip, deflate, br',
            clientTcpRtt: 12,
            colo: 'LHR',
            tlsClientAuth: {
              certIssuerDNLegacy: '',
              certIssuerDN: '',
              certIssuerDNRFC2253: '',
              certSubjectDNLegacy: '',
              certVerified: 'NONE',
              certNotAfter: '',
              certSubjectDN: '',
              certFingerprintSHA1: '',
              certNotBefore: '',
              certSerial: '',
              certPresented: '0',
              certSubjectDNRFC2253: '',
            },
            asn: 5089,
          },
        },
      },
    }

But for some reason await renderer.default(local_req, response) just... vanishes. Doesn't throw an exception, that'd be caught. Just causes Workers to think The script will never generate a response.

I'm stuck. Can I suggest using FAB server endpoints instead in the interim? 😬

@geelen
Copy link
Contributor

geelen commented Oct 20, 2020

Current status:

So I've finally tracked down something here, but I have no idea what the hell is going on. I have some levers to pull to fix it but I thought I'd dump out what I'm seeing in case this problem, or something like it, comes up again (pls no).

The failure occurs, it seems, in either raw-body or iconv-lite. This is from the compiled .next/serverless/pages/api/time.js file, but matches with the following line in raw-body: https://github.com/stream-utils/raw-body/blob/1014dae848cce5ba5f7e926c7391afc451d5d8d0/index.js#L32-L56

e.exports = getRawBody
var c = /^Encoding not recognized: /
function getDecoder(e) {
  if (!e) return null
  try {
    return a.getDecoder(e)
  } catch (t) {
    if (!c.test(t.message)) throw t
    throw n(415, 'specified encoding unsupported', {
      encoding: e,
      type: 'encoding.unsupported',
    })
  }
}

Now, I added some logging in the FAB server.js:

function getDecoder(e) {
  console.log('getDecoder')
  console.log(!e)
  if (!e) return null;
  try {
    console.log("WE TRY")
    console.log({a})
    return a.getDecoder(e);
  } catch (t) {
    console.log("WE FAIL")
    console.log({t})
    console.log(!c.test(t.message))
    if (!c.test(t.message)) throw t;
    console.log("throw time")
    throw n(415, "specified encoding unsupported", {
      encoding: e,
      type: "encoding.unsupported"
    });
  }
}

The a.getDecoder(e) line appears to be calling into iconv-lite, sort of matching up with this source code but not exactly: https://github.com/ashtuchkin/iconv-lite/blob/2be15b038afa435aae0542ff05b73ac60e3bb52a/lib/index.js#L122-L133

a.getDecoder = function getDecoder(e, t) {
  var r = a.getCodec(e),
    i = new r.decoder(t, r)
  if (r.bomAware && !(t && t.stripBOM === false)) i = new n.StripBOM(i, t)
  return i
}

This is all being injected by Next's insistence on using separately pre-compiled libraries, which is also what's bloating the bundle size I think: https://github.com/vercel/next.js/blob/84b89c8b24a0f4157cbf38a5d1f09162195a325d/packages/next/compiled/raw-body/index.js

Anyway, I threw in some logging here too:

a.getDecoder = function getDecoder(e, t) {
  console.log("A.GETDECODER")
  var r = a.getCodec(e), i = new r.decoder(t, r);
  if (r.bomAware && !(t && t.stripBOM === false)) i = new n.StripBOM(i, t);
  return i;
};

And then this is what happens with the first call:

logs: [
  { message: [{ renderer: {} }], level: 'log', timestamp: 1603207623628 },
  { message: ['WE A DEFAULT FUNCTION'], level: 'log', timestamp: 1603207623628 },
  {
    message: ['I think this is the renderer...'],
    level: 'log',
    timestamp: 1603207623628,
  },
  { message: ['ARE WE HERE OK'], level: 'log', timestamp: 1603207623628 },
  { message: ['Loaded the resolver'], level: 'log', timestamp: 1603207623628 },
  { message: ['API RESOLVER FUNCTION'], level: 'log', timestamp: 1603207623628 },
  { message: ['TRY'], level: 'log', timestamp: 1603207623628 },
  { message: [{ resolverModule: {} }], level: 'log', timestamp: 1603207623628 },
  { message: [{ config: {} }], level: 'log', timestamp: 1603207623628 },
  { message: [{ bodyParser: true }], level: 'log', timestamp: 1603207623628 },
  {
    message: [{ externalResolver: false }],
    level: 'log',
    timestamp: 1603207623628,
  },
  { message: [{ query: {} }], level: 'log', timestamp: 1603207623628 },
  { message: ['BODY PARSER'], level: 'log', timestamp: 1603207623628 },
  { message: ['PARSE BODY'], level: 'log', timestamp: 1603207623628 },
  {
    message: [{ contentType: { parameters: {}, type: 'application/json' } }],
    level: 'log',
    timestamp: 1603207623628,
  },
  { message: [{ encoding: 'utf-8' }], level: 'log', timestamp: 1603207623628 },
  { message: ['try buffer'], level: 'log', timestamp: 1603207623628 },
  { message: [{ _rawBody: {} }], level: 'log', timestamp: 1603207623628 },
  { message: [{}], level: 'log', timestamp: 1603207623628 },
  { message: ['getRawBody'], level: 'log', timestamp: 1603207623628 },
  { message: ['readStream'], level: 'log', timestamp: 1603207623628 },
  { message: ['getDecoder'], level: 'log', timestamp: 1603207623628 },
  { message: [false], level: 'log', timestamp: 1603207623628 },
  { message: ['WE TRY'], level: 'log', timestamp: 1603207623628 },
  {
    message: [
      {
        a: {
          encodings: null,
          defaultCharUnicode: '�',
          defaultCharSingleByte: '?',
          _codecDataCache: {},
        },
      },
    ],
    level: 'log',
    timestamp: 1603207623628,
  },
  { message: ['A.GETDECODER'], level: 'log', timestamp: 1603207623628 },
  { message: ['onEnd'], level: 'log', timestamp: 1603207623628 },
  { message: ['cleanup'], level: 'log', timestamp: 1603207623628 },
  { message: ['buffer ok'], level: 'log', timestamp: 1603207623628 },
  { message: [{ body: '' }], level: 'log', timestamp: 1603207623628 },
  { message: ['JSON'], level: 'log', timestamp: 1603207623628 },
  { message: ['HALF WAY'], level: 'log', timestamp: 1603207623628 },
  { message: ['ALMOST READY'], level: 'log', timestamp: 1603207623628 },
  { message: [{}], level: 'log', timestamp: 1603207623628 },
  { message: ['call the resolver'], level: 'log', timestamp: 1603207623628 },
  { message: ['I AM HERE'], level: 'log', timestamp: 1603207623628 },
  { message: ['NOW HERE'], level: 'log', timestamp: 1603207623628 },
  { message: ['OH LORD'], level: 'log', timestamp: 1603207623628 },
  { message: ['I HERE'], level: 'log', timestamp: 1603207623628 },
  { message: ['OMAR COMIN'], level: 'log', timestamp: 1603207623628 },
  { message: ['HOO BOY'], level: 'log', timestamp: 1603207623628 },
  { message: ['WE DUN'], level: 'log', timestamp: 1603207623628 },
  { message: ['finished calling'], level: 'log', timestamp: 1603207623628 },
  { message: ['Ran the resolver!'], level: 'log', timestamp: 1603207623628 },
  {
    message: ['WE FINISHED AWAITING, TIME TO RESPOND'],
    level: 'log',
    timestamp: 1603207623628,
  },
],

And the second time, when it fails:

logs: [
  { message: [{ renderer: {} }], level: 'log', timestamp: 1603207628688 },
  { message: ['WE A DEFAULT FUNCTION'], level: 'log', timestamp: 1603207628688 },
  {
    message: ['I think this is the renderer...'],
    level: 'log',
    timestamp: 1603207628688,
  },
  { message: ['ARE WE HERE OK'], level: 'log', timestamp: 1603207628688 },
  { message: ['Loaded the resolver'], level: 'log', timestamp: 1603207628688 },
  { message: ['API RESOLVER FUNCTION'], level: 'log', timestamp: 1603207628688 },
  { message: ['TRY'], level: 'log', timestamp: 1603207628688 },
  { message: [{ resolverModule: {} }], level: 'log', timestamp: 1603207628688 },
  { message: [{ config: {} }], level: 'log', timestamp: 1603207628688 },
  { message: [{ bodyParser: true }], level: 'log', timestamp: 1603207628688 },
  {
    message: [{ externalResolver: false }],
    level: 'log',
    timestamp: 1603207628688,
  },
  { message: [{ query: {} }], level: 'log', timestamp: 1603207628688 },
  { message: ['BODY PARSER'], level: 'log', timestamp: 1603207628688 },
  { message: ['PARSE BODY'], level: 'log', timestamp: 1603207628688 },
  {
    message: [{ contentType: { parameters: {}, type: 'application/json' } }],
    level: 'log',
    timestamp: 1603207628688,
  },
  { message: [{ encoding: 'utf-8' }], level: 'log', timestamp: 1603207628688 },
  { message: ['try buffer'], level: 'log', timestamp: 1603207628688 },
  { message: [{ _rawBody: {} }], level: 'log', timestamp: 1603207628688 },
  { message: [{}], level: 'log', timestamp: 1603207628688 },
  { message: ['getRawBody'], level: 'log', timestamp: 1603207628688 },
  { message: ['readStream'], level: 'log', timestamp: 1603207628688 },
  { message: ['getDecoder'], level: 'log', timestamp: 1603207628688 },
  { message: [false], level: 'log', timestamp: 1603207628688 },
  { message: ['WE TRY'], level: 'log', timestamp: 1603207628688 },
  {
    message: [
      {
        a: {
          encodings: {
            '437': 'cp437',
            '737': 'cp737',
            '775': 'cp775',
            '808': 'cp808',
            '850': 'cp850',
            '852': 'cp852',
            '855': 'cp855',
            '856': 'cp856',
            '857': 'cp857',
            '858': 'cp858',
            '860': 'cp860',
            '861': 'cp861',
            '862': 'cp862',
            '863': 'cp863',
            '864': 'cp864',
            '865': 'cp865',
            '866': 'cp866',
            '869': 'cp869',
            '874': 'windows874',
            '922': 'cp922',
            '932': 'shiftjis',
            '936': 'cp936',
            '949': 'cp949',
            '950': 'cp950',
            '1046': 'cp1046',
            '1124': 'cp1124',
            '1125': 'cp1125',
            '1129': 'cp1129',
            '1133': 'cp1133',
            '1161': 'cp1161',
            '1162': 'cp1162',
            '1163': 'cp1163',
            '1250': 'windows1250',
            '1251': 'windows1251',
            '1252': 'windows1252',
            '1253': 'windows1253',
            '1254': 'windows1254',
            '1255': 'windows1255',
            '1256': 'windows1256',
            '1257': 'windows1257',
            '1258': 'windows1258',
            '10000': 'macroman',
            '10006': 'macgreek',
            '10007': 'maccyrillic',
            '10029': 'maccenteuro',
            '10079': 'maciceland',
            '10081': 'macturkish',
            '20866': 'koi8r',
            '21866': 'koi8u',
            '28591': 'iso88591',
            '28592': 'iso88592',
            '28593': 'iso88593',
            '28594': 'iso88594',
            '28595': 'iso88595',
            '28596': 'iso88596',
            '28597': 'iso88597',
            '28598': 'iso88598',
            '28599': 'iso88599',
            '28600': 'iso885910',
            '28601': 'iso885911',
            '28603': 'iso885913',
            '28604': 'iso885914',
            '28605': 'iso885915',
            '28606': 'iso885916',
            utf8: { type: '_internal', bomAware: true },
            cesu8: { type: '_internal', bomAware: true },
            unicode11utf8: 'utf8',
            ucs2: { type: '_internal', bomAware: true },
            utf16le: 'ucs2',
            binary: { type: '_internal' },
            base64: { type: '_internal' },
            hex: { type: '_internal' },
            unicode11utf7: 'utf7',
            maccenteuro: {
              type: '_sbcs',
              chars: 'ÄĀāÉĄÖÜáąČäčĆć鏟ĎíďĒēĖóėôöõúĚěü†°Ę£§•¶ß®©™ę¨≠ģĮįĪ≤≥īĶ∂∑łĻļĽľĹĺŅņѬ√ńŇ∆«»… ňŐÕőŌ–—“”‘’÷◊ōŔŕŘ‹›řŖŗŠ‚„šŚśÁŤťÍŽžŪÓÔūŮÚůŰűŲųÝýķŻŁżĢˇ',
            },
            ibm808: 'cp808',
            cp808: {
              type: '_sbcs',
              chars: 'АБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмноп░▒▓│┤╡╢╖╕╣║╗╝╜╛┐└┴┬├─┼╞╟╚╔╩╦╠═╬╧╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀рстуфхцчшщъыьэюяЁёЄєЇїЎў°∙·√№€■ ',
            },
            mik: {
              type: '_sbcs',
              chars: 'АБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыьэюя└┴┬├─┼╣║╚╔╩╦╠═╬┐░▒▓│┤№§╗╝┘┌█▄▌▐▀αßΓπΣσµτΦΘΩδ∞φε∩≡±≥≤⌠⌡÷≈°∙·√ⁿ²■ ',
            },
            ascii8bit: 'ascii',
            usascii: 'ascii',
            ansix34: 'ascii',
            ansix341968: 'ascii',
            ansix341986: 'ascii',
            csascii: 'ascii',
            cp367: 'ascii',
            ibm367: 'ascii',
            isoir6: 'ascii',
            iso646us: 'ascii',
            iso646irv: 'ascii',
            us: 'ascii',
            latin1: 'iso88591',
            latin2: 'iso88592',
            latin3: 'iso88593',
            latin4: 'iso88594',
            latin5: 'iso88599',
            latin6: 'iso885910',
            latin7: 'iso885913',
            latin8: 'iso885914',
            latin9: 'iso885915',
            latin10: 'iso885916',
            csisolatin1: 'iso88591',
            csisolatin2: 'iso88592',
            csisolatin3: 'iso88593',
            csisolatin4: 'iso88594',
            csisolatincyrillic: 'iso88595',
            csisolatinarabic: 'iso88596',
            csisolatingreek: 'iso88597',
            csisolatinhebrew: 'iso88598',
            csisolatin5: 'iso88599',
            csisolatin6: 'iso885910',
            l1: 'iso88591',
            l2: 'iso88592',
            l3: 'iso88593',
            l4: 'iso88594',
            l5: 'iso88599',
            l6: 'iso885910',
            l7: 'iso885913',
            l8: 'iso885914',
            l9: 'iso885915',
            l10: 'iso885916',
            isoir14: 'iso646jp',
            isoir57: 'iso646cn',
            isoir100: 'iso88591',
            isoir101: 'iso88592',
            isoir109: 'iso88593',
            isoir110: 'iso88594',
            isoir144: 'iso88595',
            isoir127: 'iso88596',
            isoir126: 'iso88597',
            isoir138: 'iso88598',
            isoir148: 'iso88599',
            isoir157: 'iso885910',
            isoir166: 'tis620',
            isoir179: 'iso885913',
            isoir199: 'iso885914',
            isoir203: 'iso885915',
            isoir226: 'iso885916',
            cp819: 'iso88591',
            ibm819: 'iso88591',
            cyrillic: 'iso88595',
            arabic: 'iso88596',
            arabic8: 'iso88596',
            ecma114: 'iso88596',
            asmo708: 'iso88596',
            greek: 'iso88597',
            greek8: 'iso88597',
            ecma118: 'iso88597',
            elot928: 'iso88597',
            hebrew: 'iso88598',
            hebrew8: 'iso88598',
            turkish: 'iso88599',
            turkish8: 'iso88599',
            thai: 'iso885911',
            thai8: 'iso885911',
            celtic: 'iso885914',
            celtic8: 'iso885914',
            isoceltic: 'iso885914',
            tis6200: 'tis620',
            tis62025291: 'tis620',
            tis62025330: 'tis620',
            cspc8codepage437: 'cp437',
            cspc775baltic: 'cp775',
            cspc850multilingual: 'cp850',
            cspcp852: 'cp852',
            cspc862latinhebrew: 'cp862',
            cpgr: 'cp869',
            msee: 'cp1250',
            mscyrl: 'cp1251',
            msansi: 'cp1252',
            msgreek: 'cp1253',
            msturk: 'cp1254',
            mshebr: 'cp1255',
            msarab: 'cp1256',
            winbaltrim: 'cp1257',
            cp20866: 'koi8r',
            ibm878: 'koi8r',
            cskoi8r: 'koi8r',
            cp21866: 'koi8u',
            ibm1168: 'koi8u',
            strk10482002: 'rk1048',
            tcvn5712: 'tcvn',
            tcvn57121: 'tcvn',
            gb198880: 'iso646cn',
            cn: 'iso646cn',
            csiso14jisc6220ro: 'iso646jp',
            jisc62201969ro: 'iso646jp',
            jp: 'iso646jp',
            cshproman8: 'hproman8',
            r8: 'hproman8',
            roman8: 'hproman8',
            xroman8: 'hproman8',
            ibm1051: 'hproman8',
            mac: 'macintosh',
            csmacintosh: 'macintosh',
            windows874: {
              type: '_sbcs',
              chars: '€����…�����������‘’“”•–—�������� กขฃคฅฆงจฉชซฌญฎฏฐฑฒณดตถทธนบปผฝพฟภมยรฤลฦวศษสหฬอฮฯะัาำิีึืฺุู����฿เแโใไๅๆ็่้๊๋์ํ๎๏๐๑๒๓๔๕๖๗๘๙๚๛����',
            },
            win874: 'windows874',
            cp874: 'windows874',
            windows1250: {
              type: '_sbcs',
              chars: '€�‚�„…†‡�‰Š‹ŚŤŽŹ�‘’“”•–—�™š›śťžź ˇ˘Ł¤Ą¦§¨©Ş«¬­®Ż°±˛ł´µ¶·¸ąş»Ľ˝ľżŔÁÂĂÄĹĆÇČÉĘËĚÍÎĎĐŃŇÓÔŐÖ×ŘŮÚŰÜÝŢßŕáâăäĺćçčéęëěíîďđńňóôőö÷řůúűüýţ˙',
            },
            win1250: 'windows1250',
            cp1250: 'windows1250',
            windows1251: {
              type: '_sbcs',
              chars: 'ЂЃ‚ѓ„…†‡€‰Љ‹ЊЌЋЏђ‘’“”•–—�™љ›њќћџ ЎўЈ¤Ґ¦§Ё©Є«¬­®Ї°±Ііґµ¶·ё№є»јЅѕїАБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыьэюя',
            },
            win1251: 'windows1251',
            cp1251: 'windows1251',
            windows1252: {
              type: '_sbcs',
              chars: '€�‚ƒ„…†‡ˆ‰Š‹Œ�Ž��‘’“”•–—˜™š›œ�žŸ ¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ',
            },
            win1252: 'windows1252',
            cp1252: 'windows1252',
            windows1253: {
              type: '_sbcs',
              chars: '€�‚ƒ„…†‡�‰�‹�����‘’“”•–—�™�›���� ΅Ά£¤¥¦§¨©�«¬­®―°±²³΄µ¶·ΈΉΊ»Ό½ΎΏΐΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡ�ΣΤΥΦΧΨΩΪΫάέήίΰαβγδεζηθικλμνξοπρςστυφχψωϊϋόύώ�',
            },
            win1253: 'windows1253',
            cp1253: 'windows1253',
            windows1254: {
              type: '_sbcs',
              chars: '€�‚ƒ„…†‡ˆ‰Š‹Œ����‘’“”•–—˜™š›œ��Ÿ ¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏĞÑÒÓÔÕÖ×ØÙÚÛÜİŞßàáâãäåæçèéêëìíîïğñòóôõö÷øùúûüışÿ',
            },
            win1254: 'windows1254',
            cp1254: 'windows1254',
            windows1255: {
              type: '_sbcs',
              chars: '€�‚ƒ„…†‡ˆ‰�‹�����‘’“”•–—˜™�›���� ¡¢£₪¥¦§¨©×«¬­®¯°±²³´µ¶·¸¹÷»¼½¾¿ְֱֲֳִֵֶַָֹֺֻּֽ־ֿ׀ׁׂ׃װױײ׳״�������אבגדהוזחטיךכלםמןנסעףפץצקרשת��‎‏�',
            },
            win1255: 'windows1255',
            cp1255: 'windows1255',
            windows1256: {
              type: '_sbcs',
              chars: '€پ‚ƒ„…†‡ˆ‰ٹ‹Œچژڈگ‘’“”•–—ک™ڑ›œ‌‍ں ،¢£¤¥¦§¨©ھ«¬­®¯°±²³´µ¶·¸¹؛»¼½¾؟ہءآأؤإئابةتثجحخدذرزسشصض×طظعغـفقكàلâمنهوçèéêëىيîïًٌٍَôُِ÷ّùْûü‎‏ے',
            },
            win1256: 'windows1256',
            cp1256: 'windows1256',
            windows1257: {
              type: '_sbcs',
              chars: '€�‚�„…†‡�‰�‹�¨ˇ¸�‘’“”•–—�™�›�¯˛� �¢£¤�¦§Ø©Ŗ«¬­®Æ°±²³´µ¶·ø¹ŗ»¼½¾æĄĮĀĆÄÅĘĒČÉŹĖĢĶĪĻŠŃŅÓŌÕÖ×ŲŁŚŪÜŻŽßąįāćäåęēčéźėģķīļšńņóōõö÷ųłśūüżž˙',
            },
            win1257: 'windows1257',
            cp1257: 'windows1257',
            windows1258: {
              type: '_sbcs',
              chars: '€�‚ƒ„…†‡ˆ‰�‹Œ����‘’“”•–—˜™�›œ��Ÿ ¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂĂÄÅÆÇÈÉÊË̀ÍÎÏĐÑ̉ÓÔƠÖ×ØÙÚÛÜỮßàáâăäåæçèéêë́íîïđṇ̃óôơö÷øùúûüư₫ÿ',
            },
            win1258: 'windows1258',
            cp1258: 'windows1258',
            iso88591: {
              type: '_sbcs',
              chars: '������������������������������ ¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ',
            },
            cp28591: 'iso88591',
            iso88592: {
              type: '_sbcs',
              chars: '������������������������������ Ą˘Ł¤ĽŚ§¨ŠŞŤŹ­ŽŻ°ą˛ł´ľśˇ¸šşťź˝žżŔÁÂĂÄĹĆÇČÉĘËĚÍÎĎĐŃŇÓÔŐÖ×ŘŮÚŰÜÝŢßŕáâăäĺćçčéęëěíîďđńňóôőö÷řůúűüýţ˙',
            },
            cp28592: 'iso88592',
            iso88593: {
              type: '_sbcs',
              chars: '������������������������������ Ħ˘£¤�Ĥ§¨İŞĞĴ­�Ż°ħ²³´µĥ·¸ışğĵ½�żÀÁÂ�ÄĊĈÇÈÉÊËÌÍÎÏ�ÑÒÓÔĠÖ×ĜÙÚÛÜŬŜßàáâ�äċĉçèéêëìíîï�ñòóôġö÷ĝùúûüŭŝ˙',
            },
            cp28593: 'iso88593',
            iso88594: {
              type: '_sbcs',
              chars: '������������������������������ ĄĸŖ¤ĨĻ§¨ŠĒĢŦ­Ž¯°ą˛ŗ´ĩļˇ¸šēģŧŊžŋĀÁÂÃÄÅÆĮČÉĘËĖÍÎĪĐŅŌĶÔÕÖ×ØŲÚÛÜŨŪßāáâãäåæįčéęëėíîīđņōķôõö÷øųúûüũū˙',
            },
            cp28594: 'iso88594',
            iso88595: {
              type: '_sbcs',
              chars: '������������������������������ ЁЂЃЄЅІЇЈЉЊЋЌ­ЎЏАБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыьэюя№ёђѓєѕіїјљњћќ§ўџ',
            },
            cp28595: 'iso88595',
            iso88596: {
              type: '_sbcs',
              chars: '������������������������������ ���¤�������،­�������������؛���؟�ءآأؤإئابةتثجحخدذرزسشصضطظعغ�����ـفقكلمنهوىيًٌٍَُِّْ�������������',
            },
            cp28596: 'iso88596',
            iso88597: {
              type: '_sbcs',
              chars: '������������������������������ ‘’£€₯¦§¨©ͺ«¬­�―°±²³΄΅Ά·ΈΉΊ»Ό½ΎΏΐΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡ�ΣΤΥΦΧΨΩΪΫάέήίΰαβγδεζηθικλμνξοπρςστυφχψωϊϋόύώ�',
            },
            cp28597: 'iso88597',
            iso88598: {
              type: '_sbcs',
              chars: '������������������������������ �¢£¤¥¦§¨©×«¬­®¯°±²³´µ¶·¸¹÷»¼½¾��������������������������������‗אבגדהוזחטיךכלםמןנסעףפץצקרשת��‎‏�',
            },
            cp28598: 'iso88598',
            iso88599: {
              type: '_sbcs',
              chars: '������������������������������ ¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏĞÑÒÓÔÕÖ×ØÙÚÛÜİŞßàáâãäåæçèéêëìíîïğñòóôõö÷øùúûüışÿ',
            },
            cp28599: 'iso88599',
            iso885910: {
              type: '_sbcs',
              chars: '������������������������������ ĄĒĢĪĨĶ§ĻĐŠŦŽ­ŪŊ°ąēģīĩķ·ļđšŧž―ūŋĀÁÂÃÄÅÆĮČÉĘËĖÍÎÏÐŅŌÓÔÕÖŨØŲÚÛÜÝÞßāáâãäåæįčéęëėíîïðņōóôõöũøųúûüýþĸ',
            },
            cp28600: 'iso885910',
            iso885911: {
              type: '_sbcs',
              chars: '������������������������������ กขฃคฅฆงจฉชซฌญฎฏฐฑฒณดตถทธนบปผฝพฟภมยรฤลฦวศษสหฬอฮฯะัาำิีึืฺุู����฿เแโใไๅๆ็่้๊๋์ํ๎๏๐๑๒๓๔๕๖๗๘๙๚๛����',
            },
            cp28601: 'iso885911',
            iso885913: {
              type: '_sbcs',
              chars: '������������������������������ ”¢£¤„¦§Ø©Ŗ«¬­®Æ°±²³“µ¶·ø¹ŗ»¼½¾æĄĮĀĆÄÅĘĒČÉŹĖĢĶĪĻŠŃŅÓŌÕÖ×ŲŁŚŪÜŻŽßąįāćäåęēčéźėģķīļšńņóōõö÷ųłśūüżž’',
            },
            cp28603: 'iso885913',
            iso885914: {
              type: '_sbcs',
              chars: '������������������������������ Ḃḃ£ĊċḊ§Ẁ©ẂḋỲ­®ŸḞḟĠġṀṁ¶ṖẁṗẃṠỳẄẅṡÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏŴÑÒÓÔÕÖṪØÙÚÛÜÝŶßàáâãäåæçèéêëìíîïŵñòóôõöṫøùúûüýŷÿ',
            },
            cp28604: 'iso885914',
            iso885915: {
              type: '_sbcs',
              chars: '������������������������������ ¡¢£€¥Š§š©ª«¬­®¯°±²³Žµ¶·ž¹º»ŒœŸ¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ',
            },
            cp28605: 'iso885915',
            iso885916: {
              type: '_sbcs',
              chars: '������������������������������ ĄąŁ€„Š§š©Ș«Ź­źŻ°±ČłŽ”¶·žčș»ŒœŸżÀÁÂĂÄĆÆÇÈÉÊËÌÍÎÏĐŃÒÓÔŐÖŚŰÙÚÛÜĘȚßàáâăäćæçèéêëìíîïđńòóôőöśűùúûüęțÿ',
            },
            cp28606: 'iso885916',
            cp437: {
              type: '_sbcs',
              chars: 'ÇüéâäàåçêëèïîìÄÅÉæÆôöòûùÿÖÜ¢£¥₧ƒáíóúñѪº¿⌐¬½¼¡«»░▒▓│┤╡╢╖╕╣║╗╝╜╛┐└┴┬├─┼╞╟╚╔╩╦╠═╬╧╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀αßΓπΣσµτΦΘΩδ∞φε∩≡±≥≤⌠⌡÷≈°∙·√ⁿ²■ ',
            },
            ibm437: 'cp437',
            csibm437: 'cp437',
            cp737: {
              type: '_sbcs',
              chars: 'ΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩαβγδεζηθικλμνξοπρσςτυφχψ░▒▓│┤╡╢╖╕╣║╗╝╜╛┐└┴┬├─┼╞╟╚╔╩╦╠═╬╧╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀ωάέήϊίόύϋώΆΈΉΊΌΎΏ±≥≤ΪΫ÷≈°∙·√ⁿ²■ ',
            },
            ibm737: 'cp737',
            csibm737: 'cp737',
            cp775: {
              type: '_sbcs',
              chars: 'ĆüéāäģåćłēŖŗīŹÄÅÉæÆōöĢ¢ŚśÖÜø£ØפĀĪóŻżź”¦©®¬½¼Ł«»░▒▓│┤ĄČĘĖ╣║╗╝ĮŠ┐└┴┬├─┼ŲŪ╚╔╩╦╠═╬Žąčęėįšųūž┘┌█▄▌▐▀ÓßŌŃõÕµńĶķĻļņĒŅ’­±“¾¶§÷„°∙·¹³²■ ',
            },
            ibm775: 'cp775',
            csibm775: 'cp775',
            cp850: {
              type: '_sbcs',
              chars: 'ÇüéâäàåçêëèïîìÄÅÉæÆôöòûùÿÖÜø£Ø׃áíóúñѪº¿®¬½¼¡«»░▒▓│┤ÁÂÀ©╣║╗╝¢¥┐└┴┬├─┼ãÃ╚╔╩╦╠═╬¤ðÐÊËÈıÍÎÏ┘┌█▄¦Ì▀ÓßÔÒõÕµþÞÚÛÙýݯ´­±‗¾¶§÷¸°¨·¹³²■ ',
            },
            ibm850: 'cp850',
            csibm850: 'cp850',
            cp852: {
              type: '_sbcs',
              chars: 'ÇüéâäůćçłëŐőîŹÄĆÉĹĺôöĽľŚśÖÜŤťŁ×čáíóúĄąŽžĘ꬟Ⱥ«»░▒▓│┤ÁÂĚŞ╣║╗╝Żż┐└┴┬├─┼Ăă╚╔╩╦╠═╬¤đĐĎËďŇÍÎě┘┌█▄ŢŮ▀ÓßÔŃńňŠšŔÚŕŰýÝţ´­˝˛ˇ˘§÷¸°¨˙űŘř■ ',
            },
            ibm852: 'cp852',
            csibm852: 'cp852',
            cp855: {
              type: '_sbcs',
              chars: 'ђЂѓЃёЁєЄѕЅіІїЇјЈљЉњЊћЋќЌўЎџЏюЮъЪаАбБцЦдДеЕфФгГ«»░▒▓│┤хХиИ╣║╗╝йЙ┐└┴┬├─┼кК╚╔╩╦╠═╬¤лЛмМнНоОп┘┌█▄Пя▀ЯрРсСтТуУжЖвВьЬ№­ыЫзЗшШэЭщЩчЧ§■ ',
            },
            ibm855: 'cp855',
            csibm855: 'cp855',
            cp856: {
              type: '_sbcs',
              chars: 'אבגדהוזחטיךכלםמןנסעףפץצקרשת�£�×����������®¬½¼�«»░▒▓│┤���©╣║╗╝¢¥┐└┴┬├─┼��╚╔╩╦╠═╬¤���������┘┌█▄¦�▀������µ�������¯´­±‗¾¶§÷¸°¨·¹³²■ ',
            },
            ibm856: 'cp856',
            csibm856: 'cp856',
            cp857: {
              type: '_sbcs',
              chars: 'ÇüéâäàåçêëèïîıÄÅÉæÆôöòûùİÖÜø£ØŞşáíóúñÑĞ𿮬½¼¡«»░▒▓│┤ÁÂÀ©╣║╗╝¢¥┐└┴┬├─┼ãÃ╚╔╩╦╠═╬¤ºªÊËÈ�ÍÎÏ┘┌█▄¦Ì▀ÓßÔÒõÕµ�×ÚÛÙìÿ¯´­±�¾¶§÷¸°¨·¹³²■ ',
            },
            ibm857: 'cp857',
            csibm857: 'cp857',
            cp858: {
              type: '_sbcs',
              chars: 'ÇüéâäàåçêëèïîìÄÅÉæÆôöòûùÿÖÜø£Ø׃áíóúñѪº¿®¬½¼¡«»░▒▓│┤ÁÂÀ©╣║╗╝¢¥┐└┴┬├─┼ãÃ╚╔╩╦╠═╬¤ðÐÊËÈ€ÍÎÏ┘┌█▄¦Ì▀ÓßÔÒõÕµþÞÚÛÙýݯ´­±‗¾¶§÷¸°¨·¹³²■ ',
            },
            ibm858: 'cp858',
            csibm858: 'cp858',
            cp860: {
              type: '_sbcs',
              chars: 'ÇüéâãàÁçêÊèÍÔìÃÂÉÀÈôõòÚùÌÕÜ¢£Ù₧ÓáíóúñѪº¿Ò¬½¼¡«»░▒▓│┤╡╢╖╕╣║╗╝╜╛┐└┴┬├─┼╞╟╚╔╩╦╠═╬╧╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀αßΓπΣσµτΦΘΩδ∞φε∩≡±≥≤⌠⌡÷≈°∙·√ⁿ²■ ',
            },
            ibm860: 'cp860',
            csibm860: 'cp860',
            cp861: {
              type: '_sbcs',
              chars: 'ÇüéâäàåçêëèÐðÞÄÅÉæÆôöþûÝýÖÜø£Ø₧ƒáíóúÁÍÓÚ¿⌐¬½¼¡«»░▒▓│┤╡╢╖╕╣║╗╝╜╛┐└┴┬├─┼╞╟╚╔╩╦╠═╬╧╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀αßΓπΣσµτΦΘΩδ∞φε∩≡±≥≤⌠⌡÷≈°∙·√ⁿ²■ ',
            },
            ibm861: 'cp861',
            csibm861: 'cp861',
            cp862: {
              type: '_sbcs',
              chars: 'אבגדהוזחטיךכלםמןנסעףפץצקרשת¢£¥₧ƒáíóúñѪº¿⌐¬½¼¡«»░▒▓│┤╡╢╖╕╣║╗╝╜╛┐└┴┬├─┼╞╟╚╔╩╦╠═╬╧╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀αßΓπΣσµτΦΘΩδ∞φε∩≡±≥≤⌠⌡÷≈°∙·√ⁿ²■ ',
            },
            ibm862: 'cp862',
            csibm862: 'cp862',
            cp863: {
              type: '_sbcs',
              chars: 'ÇüéâÂà¶çêëèïî‗À§ÉÈÊôËÏûù¤ÔÜ¢£ÙÛƒ¦´óú¨¸³¯Î⌐¬½¼¾«»░▒▓│┤╡╢╖╕╣║╗╝╜╛┐└┴┬├─┼╞╟╚╔╩╦╠═╬╧╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀αßΓπΣσµτΦΘΩδ∞φε∩≡±≥≤⌠⌡÷≈°∙·√ⁿ²■ ',
            },
            ibm863: 'cp863',
            csibm863: 'cp863',
            cp864: {
              type: '_sbcs',
              chars: '\u0000\u0001\u0002\u0003\u0004\u0005\u0006\u0007\b\t\n\u000b\f\r\u000e\u000f\u0010\u0011\u0012\u0013\u0014\u0015\u0016\u0017\u0018\u0019\u001a\u001b\u001c\u001d\u001e\u001f !"#$٪&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~°·∙√▒─│┼┤┬├┴┐┌└┘β∞φ±½¼≈«»ﻷﻸ��ﻻﻼ� ­ﺂ£¤ﺄ��ﺎﺏﺕﺙ،ﺝﺡﺥ٠١٢٣٤٥٦٧٨٩ﻑ؛ﺱﺵﺹ؟¢ﺀﺁﺃﺅﻊﺋﺍﺑﺓﺗﺛﺟﺣﺧﺩﺫﺭﺯﺳﺷﺻﺿﻁﻅﻋﻏ¦¬÷×ﻉـﻓﻗﻛﻟﻣﻧﻫﻭﻯﻳﺽﻌﻎﻍﻡﹽّﻥﻩﻬﻰﻲﻐﻕﻵﻶﻝﻙﻱ■�',
            },
            ibm864: 'cp864',
            csibm864: 'cp864',
            cp865: {
              type: '_sbcs',
              chars: 'ÇüéâäàåçêëèïîìÄÅÉæÆôöòûùÿÖÜø£Ø₧ƒáíóúñѪº¿⌐¬½¼¡«¤░▒▓│┤╡╢╖╕╣║╗╝╜╛┐└┴┬├─┼╞╟╚╔╩╦╠═╬╧╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀αßΓπΣσµτΦΘΩδ∞φε∩≡±≥≤⌠⌡÷≈°∙·√ⁿ²■ ',
            },
            ibm865: 'cp865',
            csibm865: 'cp865',
            cp866: {
              type: '_sbcs',
              chars: 'АБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмноп░▒▓│┤╡╢╖╕╣║╗╝╜╛┐└┴┬├─┼╞╟╚╔╩╦╠═╬╧╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀рстуфхцчшщъыьэюяЁёЄєЇїЎў°∙·√№¤■ ',
            },
            ibm866: 'cp866',
            csibm866: 'cp866',
            cp869: {
              type: '_sbcs',
              chars: '������Ά�·¬¦‘’Έ―ΉΊΪΌ��ΎΫ©Ώ²³ά£έήίϊΐόύΑΒΓΔΕΖΗ½ΘΙ«»░▒▓│┤ΚΛΜΝ╣║╗╝ΞΟ┐└┴┬├─┼ΠΡ╚╔╩╦╠═╬ΣΤΥΦΧΨΩαβγ┘┌█▄δε▀ζηθικλμνξοπρσςτ΄­±υφχ§ψ΅°¨ωϋΰώ■ ',
            },
            ibm869: 'cp869',
            csibm869: 'cp869',
            cp922: {
              type: '_sbcs',
              chars: '������������������������������ ¡¢£¤¥¦§¨©ª«¬­®‾°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏŠÑÒÓÔÕÖ×ØÙÚÛÜÝŽßàáâãäåæçèéêëìíîïšñòóôõö÷øùúûüýžÿ',
            },
            ibm922: 'cp922',
            csibm922: 'cp922',
            cp1046: {
              type: '_sbcs',
              chars: 'ﺈ×÷ﹱ�■│─┐┌└┘ﹹﹻﹽﹿﹷﺊﻰﻳﻲﻎﻏﻐﻶﻸﻺﻼ ¤ﺋﺑﺗﺛﺟﺣ،­ﺧﺳ٠١٢٣٤٥٦٧٨٩ﺷ؛ﺻﺿﻊ؟ﻋءآأؤإئابةتثجحخدذرزسشصضطﻇعغﻌﺂﺄﺎﻓـفقكلمنهوىيًٌٍَُِّْﻗﻛﻟﻵﻷﻹﻻﻣﻧﻬﻩ�',
            },
            ibm1046: 'cp1046',
            csibm1046: 'cp1046',
            cp1124: {
              type: '_sbcs',
              chars: '������������������������������ ЁЂҐЄЅІЇЈЉЊЋЌ­ЎЏАБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыьэюя№ёђґєѕіїјљњћќ§ўџ',
            },
            ibm1124: 'cp1124',
            csibm1124: 'cp1124',
            cp1125: {
              type: '_sbcs',
              chars: 'АБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмноп░▒▓│┤╡╢╖╕╣║╗╝╜╛┐└┴┬├─┼╞╟╚╔╩╦╠═╬╧╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀рстуфхцчшщъыьэюяЁёҐґЄєІіЇї·√№¤■ ',
            },
            ibm1125: 'cp1125',
            csibm1125: 'cp1125',
            cp1129: {
              type: '_sbcs',
              chars: '������������������������������ ¡¢£¤¥¦§œ©ª«¬­®¯°±²³Ÿµ¶·Œ¹º»¼½¾¿ÀÁÂĂÄÅÆÇÈÉÊË̀ÍÎÏĐÑ̉ÓÔƠÖ×ØÙÚÛÜỮßàáâăäåæçèéêë́íîïđṇ̃óôơö÷øùúûüư₫ÿ',
            },
            ibm1129: 'cp1129',
            csibm1129: 'cp1129',
            cp1133: {
              type: '_sbcs',
              chars: '������������������������������ ກຂຄງຈສຊຍດຕຖທນບປຜຝພຟມຢຣລວຫອຮ���ຯະາຳິີຶືຸູຼັົຽ���ເແໂໃໄ່້໊໋໌ໍໆ�ໜໝ₭����������������໐໑໒໓໔໕໖໗໘໙��¢¬¦�',
            },
            ibm1133: 'cp1133',
            csibm1133: 'cp1133',
            cp1161: {
              type: '_sbcs',
              chars: '��������������������������������่กขฃคฅฆงจฉชซฌญฎฏฐฑฒณดตถทธนบปผฝพฟภมยรฤลฦวศษสหฬอฮฯะัาำิีึืฺุู้๊๋€฿เแโใไๅๆ็่้๊๋์ํ๎๏๐๑๒๓๔๕๖๗๘๙๚๛¢¬¦ ',
            },
            ibm1161: 'cp1161',
            csibm1161: 'cp1161',
            cp1162: {
              type: '_sbcs',
              chars: '€����…�����������‘’“”•–—������ กขฃคฅฆงจฉชซฌญฎฏฐฑฒณดตถทธนบปผฝพฟภมยรฤลฦวศษสหฬอฮฯะัาำิีึืฺุู����฿เแโใไๅๆ็่้๊๋์ํ๎๏๐๑๒๓๔๕๖๗๘๙๚๛����',
            },
            ibm1162: 'cp1162',
            csibm1162: 'cp1162',
            cp1163: {
              type: '_sbcs',
              chars: '������������������������������ ¡¢£€¥¦§œ©ª«¬­®¯°±²³Ÿµ¶·Œ¹º»¼½¾¿ÀÁÂĂÄÅÆÇÈÉÊË̀ÍÎÏĐÑ̉ÓÔƠÖ×ØÙÚÛÜỮßàáâăäåæçèéêë́íîïđṇ̃óôơö÷øùúûüư₫ÿ',
            },
            ibm1163: 'cp1163',
            csibm1163: 'cp1163',
            maccroatian: {
              type: '_sbcs',
              chars: 'ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®Š™´¨≠ŽØ∞±≤≥∆µ∂∑∏š∫ªºΩžø¿¡¬√ƒ≈Ć«Č… ÀÃÕŒœĐ—“”‘’÷◊�©⁄¤‹›Æ»–·‚„‰ÂćÁčÈÍÎÏÌÓÔđÒÚÛÙıˆ˜¯πË˚¸Êæˇ',
            },
            maccyrillic: {
              type: '_sbcs',
              chars: 'АБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ†°¢£§•¶І®©™Ђђ≠Ѓѓ∞±≤≥іµ∂ЈЄєЇїЉљЊњјЅ¬√ƒ≈∆«»… ЋћЌќѕ–—“”‘’÷„ЎўЏџ№Ёёяабвгдежзийклмнопрстуфхцчшщъыьэю¤',
            },
            macgreek: {
              type: '_sbcs',
              chars: 'Ĺ²É³ÖÜ΅àâä΄¨çéèê룙î‰ôö¦­ùûü†ΓΔΘΛΞΠß®©ΣΪ§≠°·Α±≤≥¥ΒΕΖΗΙΚΜΦΫΨΩάΝ¬ΟΡ≈Τ«»… ΥΧΆΈœ–―“”‘’÷ΉΊΌΎέήίόΏύαβψδεφγηιξκλμνοπώρστθωςχυζϊϋΐΰ�',
            },
            maciceland: {
              type: '_sbcs',
              chars: 'ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûüÝ°¢£§•¶ß®©™´¨≠ÆØ∞±≤≥¥µ∂∑∏π∫ªºΩæø¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷◊ÿŸ⁄¤ÐðÞþý·‚„‰ÂÊÁËÈÍÎÏÌÓÔ�ÒÚÛÙıˆ˜¯˘˙˚¸˝˛ˇ',
            },
            macroman: {
              type: '_sbcs',
              chars: 'ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨≠ÆØ∞±≤≥¥µ∂∑∏π∫ªºΩæø¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷◊ÿŸ⁄¤‹›fifl‡·‚„‰ÂÊÁËÈÍÎÏÌÓÔ�ÒÚÛÙıˆ˜¯˘˙˚¸˝˛ˇ',
            },
            macromania: {
              type: '_sbcs',
              chars: 'ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨≠ĂŞ∞±≤≥¥µ∂∑∏π∫ªºΩăş¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷◊ÿŸ⁄¤‹›Ţţ‡·‚„‰ÂÊÁËÈÍÎÏÌÓÔ�ÒÚÛÙıˆ˜¯˘˙˚¸˝˛ˇ',
            },
            macthai: {
              type: '_sbcs',
              chars: '«»…“”�•‘’� กขฃคฅฆงจฉชซฌญฎฏฐฑฒณดตถทธนบปผฝพฟภมยรฤลฦวศษสหฬอฮฯะัาำิีึืฺุู​–—฿เแโใไๅๆ็่้๊๋์ํ™๏๐๑๒๓๔๕๖๗๘๙®©����',
            },
            macturkish: {
              type: '_sbcs',
              chars: 'ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨≠ÆØ∞±≤≥¥µ∂∑∏π∫ªºΩæø¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷◊ÿŸĞğİıŞş‡·‚„‰ÂÊÁËÈÍÎÏÌÓÔ�ÒÚÛÙ�ˆ˜¯˘˙˚¸˝˛ˇ',
            },
            macukraine: {
              type: '_sbcs',
              chars: 'АБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ†°Ґ£§•¶І®©™Ђђ≠Ѓѓ∞±≤≥іµґЈЄєЇїЉљЊњјЅ¬√ƒ≈∆«»… ЋћЌќѕ–—“”‘’÷„ЎўЏџ№Ёёяабвгдежзийклмнопрстуфхцчшщъыьэю¤',
            },
            koi8r: {
              type: '_sbcs',
              chars: '─│┌┐└┘├┤┬┴┼▀▄█▌▐░▒▓⌠■∙√≈≤≥ ⌡°²·÷═║╒ё╓╔╕╖╗╘╙╚╛╜╝╞╟╠╡Ё╢╣╤╥╦╧╨╩╪╫╬©юабцдефгхийклмнопярстужвьызшэщчъЮАБЦДЕФГХИЙКЛМНОПЯРСТУЖВЬЫЗШЭЩЧЪ',
            },
            koi8u: {
              type: '_sbcs',
              chars: '─│┌┐└┘├┤┬┴┼▀▄█▌▐░▒▓⌠■∙√≈≤≥ ⌡°²·÷═║╒ёє╔ії╗╘╙╚╛ґ╝╞╟╠╡ЁЄ╣ІЇ╦╧╨╩╪Ґ╬©юабцдефгхийклмнопярстужвьызшэщчъЮАБЦДЕФГХИЙКЛМНОПЯРСТУЖВЬЫЗШЭЩЧЪ',
            },
            koi8ru: {
              type: '_sbcs',
              chars: '─│┌┐└┘├┤┬┴┼▀▄█▌▐░▒▓⌠■∙√≈≤≥ ⌡°²·÷═║╒ёє╔ії╗╘╙╚╛ґў╞╟╠╡ЁЄ╣ІЇ╦╧╨╩╪ҐЎ©юабцдефгхийклмнопярстужвьызшэщчъЮАБЦДЕФГХИЙКЛМНОПЯРСТУЖВЬЫЗШЭЩЧЪ',
            },
            koi8t: {
              type: '_sbcs',
              chars: 'қғ‚Ғ„…†‡�‰ҳ‹ҲҷҶ�Қ‘’“”•–—�™�›�����ӯӮё¤ӣ¦§���«¬­®�°±²Ё�Ӣ¶·�№�»���©юабцдефгхийклмнопярстужвьызшэщчъЮАБЦДЕФГХИЙКЛМНОПЯРСТУЖВЬЫЗШЭЩЧЪ',
            },
            armscii8: {
              type: '_sbcs',
              chars: '������������������������������ �և։)(»«—.՝,-֊…՜՛՞ԱաԲբԳգԴդԵեԶզԷէԸըԹթԺժԻիԼլԽխԾծԿկՀհՁձՂղՃճՄմՅյՆնՇշՈոՉչՊպՋջՌռՍսՎվՏտՐրՑցՒւՓփՔքՕօՖֆ՚�',
            },
            rk1048: {
              type: '_sbcs',
              chars: 'ЂЃ‚ѓ„…†‡€‰Љ‹ЊҚҺЏђ‘’“”•–—�™љ›њқһџ ҰұӘ¤Ө¦§Ё©Ғ«¬­®Ү°±Ііөµ¶·ё№ғ»әҢңүАБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыьэюя',
            },
            tcvn: {
              type: '_sbcs',
              chars: '\u0000ÚỤ\u0003ỪỬỮ\u0007\b\t\n\u000b\f\r\u000e\u000f\u0010ỨỰỲỶỸÝỴ\u0018\u0019\u001a\u001b\u001c\u001d\u001e\u001f !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~ÀẢÃÁẠẶẬÈẺẼÉẸỆÌỈĨÍỊÒỎÕÓỌỘỜỞỠỚỢÙỦŨ ĂÂÊÔƠƯĐăâêôơưđẶ̀̀̉̃́àảãáạẲằẳẵắẴẮẦẨẪẤỀặầẩẫấậèỂẻẽéẹềểễếệìỉỄẾỒĩíịòỔỏõóọồổỗốộờởỡớợùỖủũúụừửữứựỳỷỹýỵỐ',
            },
            georgianacademy: {
              type: '_sbcs',
              chars: '��‚ƒ„…†‡ˆ‰Š‹Œ����‘’“”•–—˜™š›œ��Ÿ ¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿აბგდევზთიკლმნოპჟრსტუფქღყშჩცძწჭხჯჰჱჲჳჴჵჶçèéêëìíîïðñòóôõö÷øùúûüýþÿ',
            },
            georgianps: {
              type: '_sbcs',
              chars: '��‚ƒ„…†‡ˆ‰Š‹Œ����‘’“”•–—˜™š›œ��Ÿ ¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿აბგდევზჱთიკლმნჲოპჟრსტჳუფქღყშჩცძწჭხჴჯჰჵæçèéêëìíîïðñòóôõö÷øùúûüýþÿ',
            },
            pt154: {
              type: '_sbcs',
              chars: 'ҖҒӮғ„…ҶҮҲүҠӢҢҚҺҸҗ‘’“”•–—ҳҷҡӣңқһҹ ЎўЈӨҘҰ§Ё©Ә«¬ӯ®Ҝ°ұІіҙө¶·ё№ә»јҪҫҝАБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыьэюя',
            },
            viscii: {
              type: '_sbcs',
              chars: '\u0000\u0001Ẳ\u0003\u0004ẴẪ\u0007\b\t\n\u000b\f\r\u000e\u000f\u0010\u0011\u0012\u0013Ỷ\u0015\u0016\u0017\u0018Ỹ\u001a\u001b\u001c\u001dỴ\u001f !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~ẠẮẰẶẤẦẨẬẼẸẾỀỂỄỆỐỒỔỖỘỢỚỜỞỊỎỌỈỦŨỤỲÕắằặấầẩậẽẹếềểễệốồổỗỠƠộờởịỰỨỪỬơớƯÀÁÂÃẢĂẳẵÈÉÊẺÌÍĨỳĐứÒÓÔạỷừửÙÚỹỵÝỡưàáâãảăữẫèéêẻìíĩỉđựòóôõỏọụùúũủýợỮ',
            },
            iso646cn: {
              type: '_sbcs',
              chars: '\u0000\u0001\u0002\u0003\u0004\u0005\u0006\u0007\b\t\n\u000b\f\r\u000e\u000f\u0010\u0011\u0012\u0013\u0014\u0015\u0016\u0017\u0018\u0019\u001a\u001b\u001c\u001d\u001e\u001f !"#¥%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}‾��������������������������������������������������������������������������������������������������������������������������������',
            },
            iso646jp: {
              type: '_sbcs',
              chars: '\u0000\u0001\u0002\u0003\u0004\u0005\u0006\u0007\b\t\n\u000b\f\r\u000e\u000f\u0010\u0011\u0012\u0013\u0014\u0015\u0016\u0017\u0018\u0019\u001a\u001b\u001c\u001d\u001e\u001f !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[¥]^_`abcdefghijklmnopqrstuvwxyz{|}‾��������������������������������������������������������������������������������������������������������������������������������',
            },
            hproman8: {
              type: '_sbcs',
              chars: '������������������������������ ÀÂÈÊËÎÏ´ˋˆ¨˜ÙÛ₤¯Ýý°ÇçÑñ¡¿¤£¥§ƒ¢âêôûáéóúàèòùäëöüÅîØÆåíøæÄìÖÜÉïßÔÁÃãÐðÍÌÓÒÕõŠšÚŸÿÞþ·µ¶¾—¼½ªº«■»±�',
            },
            macintosh: {
              type: '_sbcs',
              chars: 'ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨≠ÆØ∞±≤≥¥µ∂∑∏π∫ªºΩæø¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷◊ÿŸ⁄¤‹›fifl‡·‚„‰ÂÊÁËÈÍÎÏÌÓÔ�ÒÚÛÙıˆ˜¯˘˙˚¸˝˛ˇ',
            },
            ascii: {
              type: '_sbcs',
              chars: '��������������������������������������������������������������������������������������������������������������������������������',
            },
            tis620: {
              type: '_sbcs',
              chars: '���������������������������������กขฃคฅฆงจฉชซฌญฎฏฐฑฒณดตถทธนบปผฝพฟภมยรฤลฦวศษสหฬอฮฯะัาำิีึืฺุู����฿เแโใไๅๆ็่้๊๋์ํ๎๏๐๑๒๓๔๕๖๗๘๙๚๛����',
            },
            shiftjis: {
              type: '_dbcs',
              encodeAdd: { '¥': 92, '‾': 126 },
              encodeSkipVals: [{ from: 60736, to: 63808 }],
            },
            csshiftjis: 'shiftjis',
            mskanji: 'shiftjis',
            sjis: 'shiftjis',
            windows31j: 'shiftjis',
            ms31j: 'shiftjis',
            xsjis: 'shiftjis',
            windows932: 'shiftjis',
            ms932: 'shiftjis',
            cp932: 'shiftjis',
            eucjp: { type: '_dbcs', encodeAdd: { '¥': 92, '‾': 126 } },
            gb2312: 'cp936',
            gb231280: 'cp936',
            gb23121980: 'cp936',
            csgb2312: 'cp936',
            csiso58gb231280: 'cp936',
            euccn: 'cp936',
            windows936: 'cp936',
            ms936: 'cp936',
            cp936: { type: '_dbcs' },
            gbk: { type: '_dbcs' },
            xgbk: 'gbk',
            isoir58: 'gbk',
            gb18030: {
              type: '_dbcs',
              encodeSkipVals: [128],
              encodeAdd: { '€': 41699 },
            },
            chinese: 'gb18030',
            windows949: 'cp949',
            ms949: 'cp949',
            cp949: { type: '_dbcs' },
            cseuckr: 'cp949',
            csksc56011987: 'cp949',
            euckr: 'cp949',
            isoir149: 'cp949',
            korean: 'cp949',
            ksc56011987: 'cp949',
            ksc56011989: 'cp949',
            ksc5601: 'cp949',
            windows950: 'cp950',
            ms950: 'cp950',
            cp950: { type: '_dbcs' },
            big5: 'big5hkscs',
            big5hkscs: { type: '_dbcs', encodeSkipVals: [41676] },
            cnbig5: 'big5hkscs',
            csbig5: 'big5hkscs',
            xxbig5: 'big5hkscs',
          },
          defaultCharUnicode: '�',
          defaultCharSingleByte: '?',
          _codecDataCache: { utf8: { enc: 'utf8', bomAware: true } },
        },
      },
    ],
    level: 'log',
    timestamp: 1603207628688,
  },
  { message: ['A.GETDECODER'], level: 'log', timestamp: 1603207628688 },
],

So... that's different.

@geelen
Copy link
Contributor

geelen commented Oct 20, 2020

Ok that looks like not it. I hacked around with the loading of the encodings and messing around with the webpack module cache but got nowhere.

I've dug into this further and I've reached the limit of my understanding. Given this parseBody function:

    async function parseBody(req, limit) {
      console.log("PARSE BODY")
      const contentType = (0, _contentType.parse)(req.headers['content-type'] || 'text/plain');
      const {type, parameters} = contentType;
      const encoding = parameters.charset || 'utf-8';
      let buffer;
      try {
        console.log("BUFFER")
        buffer = await _rawBody.default(req, {
          encoding,
          limit
        });
        console.log("BUFFER DONE")
      } catch (e) {
        if (e.type === 'entity.too.large') {
          throw new ApiError(413, `Body exceeded ${limit} limit`);
        } else {
          throw new ApiError(400, 'Invalid body');
        }
      }
      const body = buffer.toString();
      console.log({body})
      if (type === 'application/json' || type === 'application/ld+json') {
        return parseJson(body);
      } else if (type === 'application/x-www-form-urlencoded') {
        const qs = __webpack_require__("8xkj");
        return qs.decode(body);
      } else {
        return body;
      }
    }

and this readStream body (source here):

            function readStream(e, t, r, i, a) {
              console.log("READ STREAM")
              var o = false;
              var c = true;
              if (i !== null && r !== null && r > i) {
                return done(n(413, 'request entity too large', {
                  expected: r,
                  length: r,
                  limit: i,
                  type: 'entity.too.large'
                }));
              }
              var s = e._readableState;
              if (e._decoder || s && (s.encoding || s.decoder)) {
                console.log("stream encoding should not be set")
                return done(n(500, 'stream encoding should not be set', {
                  type: 'stream.encoding.set'
                }));
              }
              var f = 0;
              var p;
              try {
                console.log("ABOUT TO GET DECODER")
                p = getDecoder(t);
              } catch (e) {
                return done(e);
              }
              var u = p ? '' : [];
              console.log({u})
              e.on('aborted', onAborted);
              e.on('close', cleanup);
              e.on('data', onData);
              e.on('end', onEnd);
              e.on('error', onEnd);
              c = false;
              console.log("Attached events to e")
              function done() {
                console.log('done')
                var t = new Array(arguments.length);
                for (var r = 0; r < t.length; r++) {
                  t[r] = arguments[r];
                }
                o = true;
                if (c) {
                  process.nextTick(invokeCallback);
                } else {
                  invokeCallback();
                }
                function invokeCallback() {
                  cleanup();
                  if (t[0]) {
                    halt(e);
                  }
                  a.apply(null, t);
                }
              }
              function onAborted() {
                console.log('onAborted')
                if (o) return;
                done(n(400, 'request aborted', {
                  code: 'ECONNABORTED',
                  expected: r,
                  length: r,
                  received: f,
                  type: 'request.aborted'
                }));
              }
              function onData(e) {
                console.log('onData')
                if (o) return;
                f += e.length;
                if (i !== null && f > i) {
                  done(n(413, 'request entity too large', {
                    limit: i,
                    received: f,
                    type: 'entity.too.large'
                  }));
                } else if (p) {
                  u += p.write(e);
                } else {
                  u.push(e);
                }
              }
              function onEnd(e) {
                console.log('onEnd')
                if (o) return;
                if (e) return done(e);
                if (r !== null && f !== r) {
                  done(n(400, 'request size did not match content length', {
                    expected: r,
                    length: r,
                    received: f,
                    type: 'request.size.invalid'
                  }));
                } else {
                  var t = p ? u + (p.end() || '') : Buffer.concat(u);
                  done(null, t);
                }
              }
              function cleanup() {
                console.log('cleanup')
                u = null;
                e.removeListener('aborted', onAborted);
                e.removeListener('data', onData);
                e.removeListener('end', onEnd);
                e.removeListener('error', onEnd);
                e.removeListener('close', cleanup);
              }
            }

(note, e is the request object passed in).

I get these logs. First time, when it works:

{"renderer":{}}
"WE A DEFAULT FUNCTION"
"PARSE BODY"
"BUFFER"
"GET RAW BODY"
"RETURNING PROMISE"
"EXECUTOR"
"READ STREAM"
"ABOUT TO GET DECODER"
"WE TRY"
"GOT THE DECODER"
{"decoder":{"decoder":{"encoding":"utf8","lastNeed":0,"lastTotal":0,"lastChar":{"type":"Buffer","data":[0,0,0,0]}},"pass":false,"options":{}}}
{"u":""}
"Attached events to e"
"onEnd"
"done"
"cleanup"
"ON READ"
{"e":null}
"BUFFER DONE"
{"body":""}
"I AM HERE"
"NOW HERE"
"OH LORD"
"I HERE"
"OMAR COMIN"
"HOO BOY"
"WE DUN"
"WE FINISHED AWAITING, TIME TO RESPOND"
[]

(last line is errors, i.e. no errors)

Second time, when it fails:

{"renderer":{}}
"WE A DEFAULT FUNCTION"
"PARSE BODY"
"BUFFER"
"GET RAW BODY"
"RETURNING PROMISE"
"EXECUTOR"
"READ STREAM"
"ABOUT TO GET DECODER"
"WE TRY"
"GOT THE DECODER"
{"decoder":{"decoder":{"encoding":"utf8","lastNeed":0,"lastTotal":0,"lastChar":{"type":"Buffer","data":[0,0,0,0]}},"pass":false,"options":{}}}
{"u":""}
"Attached events to e"
[{"name":"Error","message":"The script will never generate a response.","timestamp":1603228368312}]

So, we set up this stream to read the (totally empty) body. The first time it works, the second time it either doesn't, or CF workers environment thinks it doesn't and kills the worker...

@geelen
Copy link
Contributor

geelen commented Oct 20, 2020

Have reached out to Cloudflare for assistance. Also, just tried on HTTP2 on cURL and got this:

> curl --http2 https://fab-ci-nextjs.linc.workers.dev/api/time
{"current_time":"2020-10-20T21:27:45.532Z","before":false,"after":true}%
glen@Lil-Lise
> curl --http2 https://fab-ci-nextjs.linc.workers.dev/api/time
<!DOCTYPE html>
<!--[if lt IE 7]> <html class="no-js ie6 oldie" lang="en-US"> <![endif]-->
<!--[if IE 7]>    <html class="no-js ie7 oldie" lang="en-US"> <![endif]-->
<!--[if IE 8]>    <html class="no-js ie8 oldie" lang="en-US"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en-US"> <!--<![endif]-->
<head>
<title>Worker threw exception | fab-ci-nextjs.linc.workers.dev | Cloudflare</title></title>
...

PROGRESS

@rohanbam
Copy link

rohanbam commented Nov 2, 2020

@geelen, I was wondering if this bug was fixed or if there's any new information about it.

@geelen
Copy link
Contributor

geelen commented Nov 2, 2020

Sadly not. I have sent it to 4 different people at Cloudflare but so far no response. Hoping for some progress from them soon, but nothing yet.

@geelen
Copy link
Contributor

geelen commented Nov 15, 2020

🎉🎉🎉 SUCCESS 🎉🎉🎉

TL;DR: do this to fix it:

// api/your-endpoint.js

export default (req, res) => {
  // your existing route code here
}

// Add this export:
export const config = {
  api: {
    bodyParser: false,
  },
}

From the config documented here


So, as part of this investigation, I found:

It is definitely something to do with keep-alive/HTTP2

curl -iv https://nextjs-api-no-bueno.glen.workers.dev/api/time --next https://nextjs-api-no-bueno.glen.workers.dev/api/time

Finally, a repeatable way of triggering the crash! Thanks, @pi0!

It isn't a bug in the core of Cloudflare Workers

The error is actually The script will never generate a response, so I added this little snippet to the Cloudflare deployment template:

addEventListener('fetch', (event) => {

const timeOut = async () => {
  await new Promise((x) => setTimeout(x, 2000))
  return new Response('DIDNT FINISH IN 2 SECONDS :(', {
    headers: {
      'content-type': 'text/html',
    },
  })
}

addEventListener('fetch', (event) => {
  const request = event.request
  const url = new URL(request.url)
  if (url.protocol === 'https:') {
    const promise = Promise.race([
      handleRequest(request),
      timeOut(),
    ])
    event.respondWith(promise)
  } else {
    // ...

You can actually paste that into a worker in the dashboard too. It confirms that Cloudflare aren't being overeager with their no-possible-return-path detection.

The bug is exactly where I thought, but I still don't understand it:

The final thing the render method does before just vanishing into the aether is:

stream.on('aborted', onAborted)
stream.on('close', cleanup)
stream.on('data', onData)
stream.on('end', onEnd)
stream.on('error', onEnd)

From here: https://github.com/stream-utils/raw-body/blob/1014dae848cce5ba5f7e926c7391afc451d5d8d0/index.js#L190-L194

But stream here is actually our Request, generated by MockExpressRequest: https://github.com/lykmapipo/mock-express-request/blob/master/index.js

Given that for a GET request the body is null right from the get go, it seems crazy to me that Next is trying to parse a body that's not present by attaching event handlers to a Request that it calls stream, but that's NodeJS libraries for you. I've raised a bug: vercel/next.js#19196

NextJS binaries are way bigger than they need to be

I found myself running into script size limitations just by moving a few imports around. So many modules in Next are importing, say, the entirety of lodash or http or something just for a single key. Maybe tree shaking would work, or Closure's dead code elimination.

@Rashmi-278
Copy link
Author

Amazing !!! Thank you very much !
Really appreciate it 🙂
Wish you the best.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants