Null autotask response body, but successful tx

I'm using the OZ defender's Autotask and Relayer to perform meta-transactions. I've been following this guide on how to implement these meta-transactions - https://blog.openzeppelin.com/gasless-metatransactions-with-openzeppelin-defender/

:computer: Problem

I'm able to perform the meta-txs successfully - the autotask dashboard reports success and my transactions are processed as intended. However, I sometimes get a null response body from autotask when I perform meta-txs through my react app, instead of scripts (hardhat).

:memo:Details

This is the code my autotask is running -

const ethers = require('ethers');
const { DefenderRelaySigner, DefenderRelayProvider } = require('defender-relay-client/lib/ethers');

const ForwarderAbi = [{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"components":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"uint256","name":"gas","type":"uint256"},{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"internalType":"struct MinimalForwarder.ForwardRequest","name":"req","type":"tuple"},{"internalType":"bytes","name":"signature","type":"bytes"}],"name":"execute","outputs":[{"internalType":"bool","name":"","type":"bool"},{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"}],"name":"getNonce","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"uint256","name":"gas","type":"uint256"},{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"internalType":"struct MinimalForwarder.ForwardRequest","name":"req","type":"tuple"},{"internalType":"bytes","name":"signature","type":"bytes"}],"name":"verify","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"}];
const ForwarderAddress = "0xE361f049d4A7298dE53Cd431966ECf0de809cdf6";

async function relay(forwarder, request, signature) {
  // Validate request on the forwarder contract
  const valid = await forwarder.verify(request, signature);
  if (!valid) throw new Error(`Invalid request`);
  
  // Send meta-tx through relayer to the forwarder contract
  const gasLimit = (parseInt(request.gas) + 50000).toString();
  return await forwarder.execute(request, signature, { gasLimit });
}

async function handler(event) {
  // Parse webhook payload
  if (!event.request || !event.request.body) throw new Error(`Missing payload`);
  const { request, signature } = event.request.body;
  console.log(`Relaying`, request);
  console.log(`Signature`, signature);
  
  // Initialize Relayer provider and signer, and forwarder contract
  const credentials = { ... event };
  const provider = new DefenderRelayProvider(credentials);
  const signer = new DefenderRelaySigner(credentials, provider, { speed: 'fast' });
  const forwarder = new ethers.Contract(ForwarderAddress, ForwarderAbi, signer);
  
  // Relay transaction!
  const tx = await relay(forwarder, request, signature);
  console.log(`Sent meta-tx: ${tx.hash}`);
  const receipt = await tx.wait();
  return { txHash: tx.hash, receipt: receipt, txResponse: tx };
}

module.exports = {
  handler
}

This is how I'm getting the response from the autotask --

const response = await fetch(autoTaskURL, {
        method: "POST",
        body: JSON.stringify(txRequest),
        headers: { "Content-Type": "application/json" },
        mode: "no-cors",
      })

const parsedResponse = await response.json() // Error: Unexpected end of JSON input

Logging response to the console reveals that the response body is empty, hence (I believe) the Unexpected end of JSON input error.

Autotask reports that my code was run successfully, and indeed, my transaction is processed as intended. The issue is getting the response from autotask.

Hey @nkrishang! What happens if you remove the mode: no-cors from the request?

Works like a charm @spalladino thanks for the quick response!