Axios Write Hook in Delegated Admin Extension Causes "Unexpected End of File" Error

Overview

This article addresses an error that occurs when a Delegated Admin Extension (DAE) uses a Write Hook with Axios.

var axios = require('axios');

When a user creation event triggers the Write Hook, the following error is returned:

Unexpected End of File.

Axios Error

Applies To
  • Delegated Admin Extension
  • Axios
Cause

The error is caused by the default version of Axios (v1.2.1) that the extension uses when require('axios') is called. This specific version has an issue that results in the error. A more recent version is available, as shown in the Can I Require module directory.

The version in use can be confirmed by adding the following line to the script and observing the output in the Actions Logs:

ctx.log(`Axios version: ${axios.VERSION}`);
Solution

To resolve this issue, modify the Write Hook to explicitly require a more recent version of Axios.

  1. In the Delegated Admin Extension Write Hook, locate the line that requires the Axios module. The original line appears as follows:

    var axios = require('axios');
  2. Update this line to specify a newer version, for example, version 1.4.0.
    var axios = require('axios@1.4.0');

    Configuration Example 

Recommended content

No recommended content found...