Axios: 'Unexpected end of file' error. Code works locally but not in pipedream

Hi,

One of my functions returns an ‘Unexpected end of file’ error.
Sometimes another function fails.
The code runs without errors when I run it locally but returns errors on pipedream.

I enabled the workflow to be seen by support.

See error:

Error - update(CONTACTS):     at Function.AxiosError.from (file:///tmp/__pdg__/dist/code/fe04ba51797834b46b59382d58ec636cc75e90814f8900e2035a5ce2c414c84a/node_modules/.pnpm/axios@1.2.1/node_modules/axios/lib/core/AxiosError.js:89:14)
    at BrotliDecompress.handleStreamError (file:///tmp/__pdg__/dist/code/fe04ba51797834b46b59382d58ec636cc75e90814f8900e2035a5ce2c414c84a/node_modules/.pnpm/axios@1.2.1/node_modules/axios/lib/adapters/http.js:489:29)
    at BrotliDecompress.emit (events.js:412:35)
    at null.emitErrorNT (internal/streams/destroy.js:106:8)
    at null.emitErrorCloseNT (internal/streams/destroy.js:74:3)
    at process.processTicksAndRejections (internal/process/task_queues.js:82:21)
 {
  code: 'Z_BUF_ERROR',
  errno: -5,
  message: 'unexpected end of file',
  config: {
    transitional: {
      silentJSONParsing: true,
      forcedJSONParsing: true,
      clarifyTimeoutError: false
    },

Thanks,
Lar

Hi @lharney

Could you please share the content of your Node.js code step that’s producing this error?

Sounds like it could be a case of a missing bracket or other punctuation mark the interpreter is expecting, but we cannot help without the code itself.

Hi @pierce

The same code works in other pipedream workflows, which is strange.

    // update
    const update = async (objectType, objectID, properties) => {
      try {
        const url = `${HS_BASE_URL}/crm/v3/objects/${objectType}/${objectID}`;
        var body = { 'properties': properties };

        const response = await axios.patch(url, body, { headers: defaultHeaders });
        console.log('Updated', objectType, response.data.id);

        return response.data.id;
      } catch (error) {
        error.message.includes('Request failed')
          ? console.error('Error - update(' + objectType + '):', error.response.status, error.response.data)
          : console.error('Error - update(' + objectType + '):', error)
      }
    }

     // update contact
     await update('CONTACTS', contactId, { last_access_date: '2022-12-01'});

Thanks,
Lar

Thanks for sharing @lharney

Are you using this Node.js code in a step in a v2 workflow?

There’s new code scaffolding that warps the code in v2 workflows. Please see this section of our migration guide for more details: Migrate from v1

Without the wrapping scaffolding, the workflow won’t be able to execute your code properly.

I am using the V2 scaffolding. I can’t post all the code on a public forum.

I enabled the workflow to be seen by support if you are able to view?

I am having the same issue with axios. Does anyone know what might be the problem?

at Function.AxiosError.from (file:///tmp/pdg/dist/code/b6bd5df03ae7ffc615bf9198390ec034f118e77cd79b2a56056c86964649730f/node_modules/.pnpm/axios@1.2.1/node_modules/axios/lib/core/AxiosError.js:89:14)
at BrotliDecompress.handleStreamError (file:///tmp/pdg/dist/code/b6bd5df03ae7ffc615bf9198390ec034f118e77cd79b2a56056c86964649730f/node_modules/.pnpm/axios@1.2.1/node_modules/axios/lib/adapters/http.js:489:29)
at BrotliDecompress.emit (events.js:412:35)
at null.emitErrorNT (internal/streams/destroy.js:106:8)
at null.emitErrorCloseNT (internal/streams/destroy.js:74:3)
at process.processTicksAndRejections (internal/process/task_queues.js:82:21)
{
code: ‘Z_BUF_ERROR’,
errno: -5,
message: ‘unexpected end of file’,
config: {
transitional: {
silentJSONParsing: true,
forcedJSONParsing: true,
clarifyTimeoutError: false
},

We can provide 1:1 private support for Teams customers over Slack. But for general debugging of workflows especially code steps, we ask that you provide the code content in our public forums so staff and community alike can provide assistance.

If you need to remove hard coded API keys, we encourage the use of Environment Variables to protect sensitive information.

HI,

here is my code. It is just a simple axios.get.

// To use any npm package on Pipedream, just import it
import axios from "axios"

export default defineComponent({
  async run({ steps, $ }) {
    const url = process.env.DB_URL
    const res = await axios.get(url);
    return res
  },
})

and this is the error I get.

Error
unexpected end of file

DETAILS
    at Function.AxiosError.from (file:///tmp/__pdg__/dist/code/f72647f8405c14d4683694abe19862a4d625be4f7b57366cf5f583d6191bd482/node_modules/.pnpm/axios@1.2.1/node_modules/axios/lib/core/AxiosError.js:89:14)
    at BrotliDecompress.handleStreamError (file:///tmp/__pdg__/dist/code/f72647f8405c14d4683694abe19862a4d625be4f7b57366cf5f583d6191bd482/node_modules/.pnpm/axios@1.2.1/node_modules/axios/lib/adapters/http.js:489:29)
    at BrotliDecompress.emit (events.js:412:35)
    at null.emitErrorNT (internal/streams/destroy.js:106:8)
    at null.emitErrorCloseNT (internal/streams/destroy.js:74:3)
    at process.processTicksAndRejections (internal/process/task_queues.js:82:21)