How to Resolve AssemblyAI Source Errors and TLSSocket Issue in Pipedream?

This topic was automatically generated from Slack. You can find the original thread here.

Hi - I’m having trouble with an AssemblyAI source that listens for New Transcriptions.

  1. First the source worked fine, and I created a workflow.
  2. Then, after about 30-45min, the source began to show errors on the log. Creating a new source with the same account solved the problem temporarily.
  3. Then, the source began to show an error in the logs, it was a “400 Bad Request” error. But, the source was constructing a set of params for paginateRequests: { status: "completed", after_id: lastId, before_id: "…", limit: 10}
  4. Changing the param to { …, before_id: lastId } seemed to fix the error temporarily.
  5. Now I get an error in the source logs: “Pipedream detected that component was still running code. Make sure you await all promises. (Reason: TLSSocket)”
    Any suggestions to resolve this issue?

Hi , would you mind sharing the log for 400 Bad Request error?

sure thing. I was able to repro using the default configuration for the source. I’m not sure how the param before_id is being created based on the library code. I have my source set to update every 1 minute, and reproduced by creating a batch of three transcripts from three mp3s, then creating three new transcripts.

[debug] err.response {
  "status": 400,
  "statusText": "Bad Request",
  "headers": {
    "date": "Tue, 26 Sep 2023 08:02:14 GMT",
    "content-type": "application/json; charset=UTF-8",
    "content-length": "15",
    "connection": "close",
    "set-cookie": [
      ....
    ],
    "access-control-allow-origin": "**",
    "access-control-allow-headers": "Content-Type, Authorization, X-Requested-With",
    "access-control-allow-methods": "POST, PUT, GET, OPTIONS"
  },
  "config": {
    "url": "https://api.assemblyai.com/v2/transcript",
    "headers": {
      "Accept": "application/json, text/plain, **/*",
      "authorization": "...",
      "User-Agent": "axios/0.21.4"
    },
    "params": {
      "status": "completed",
      "after_id": "6ckjjx4zw9-0e61-4ed8-8357-e389a041cef7",
      "limit": "10",
      "before_id": "6ckpb31fzx-6b33-4d3f-a8df-cf0e08d9d740"
    },
    "transformRequest": [
      null
    ],
    "transformResponse": [
      null
    ],
    "timeout": 0,
    "xsrfCookieName": "XSRF-TOKEN",
    "xsrfHeaderName": "X-XSRF-TOKEN",
    "maxContentLength": -1,
    "maxBodyLength": -1,
    "transitional": {
      "silentJSONParsing": true,
      "forcedJSONParsing": true,
      "clarifyTimeoutError": false
    },
    "method": "get"
  },
  "data": {
    "error": null
  }
}

Here is the exact config generating that error.

import assemblyai from "../../assemblyai.app.mjs";
import { DEFAULT_POLLING_SOURCE_TIMER_INTERVAL } from "@pipedream/platform";

export default {
  name: "New Transcription Completed",
  description: "Emit new event when a transcribed audio file from AssemblyAI is ready. [See the documentation](https://www.assemblyai.com/docs/API%20reference/transcript)",
  key: "assemblyai-new-transcription-completed",
  version: "0.0.1",
  type: "source",
  dedupe: "unique",
  props: {
    assemblyai,
    db: "$.service.db",
    timer: {
      type: "$.interface.timer",
      default: {
        intervalSeconds: DEFAULT_POLLING_SOURCE_TIMER_INTERVAL,
      },
    },
  },
  hooks: {
    async deploy() {
      const { transcripts } = await this.assemblyai.listTranscripts({
        params: {
          status: "completed",
          limit: 25,
        },
      });
      if (!transcripts.length) {
        return;
      }
      this._setLastId(transcripts[0].id);
      transcripts.reverse().forEach((transcript) => this.emitEvent(transcript));
    },
  },
  methods: {
    _getLastId() {
      return this.db.get("lastId");
    },
    _setLastId(lastId) {
      this.db.set("lastId", lastId);
    },
    emitEvent(transcript) {
      const meta = this.generateMeta(transcript);
      this.$emit(transcript, meta);
    },
    generateMeta(transcript) {
      return {
        id: transcript.id,
        summary: `New Transcript ID ${transcript.id}`,
        ts: Date.now(),
      };
    },
  },
  async run() {
    const lastId = this._getLastId();
    const transcripts = await this.assemblyai.paginateTranscripts({
      params: {
        status: "completed",
        after_id: lastId,
      },
    });
    console.log("transcript count:", transcripts.length);
    if (!transcripts.length) {
      return;
    }
    transcripts.forEach((transcript) => this.emitEvent(transcript));
    this._setLastId(transcripts[0].id);
  },
};