MrRefactoring / jira.js

A JavaScript/TypeScript wrapper for the JIRA Cloud, Service Desk and Agile REST API
https://mrrefactoring.github.io/jira.js/
MIT License
349 stars 46 forks source link

InternalBinding Error when requesting field context #257

Closed vichingo closed 9 months ago

vichingo commented 1 year ago

Hi,

When trying to find the context id of a field with:

node ./src/index.js

const jira = new Version3Client({
    host: url,
    authentication: {
        basic: {
            email: email,
            apiToken: jiraApiToken,
        },
    },
    newErrorHandling: true,
})

export const getJiraFields = () => jira.issueFields.getFields()
export const getJiraCustomFieldContexts = (fieldID) => jira.issueCustomFieldContexts.getContextsForField(fieldID)
export const getJiraCustomFieldOptions = (fieldID, contextID) => jira.issueCustomFieldOptions.getOptionsForContext(fieldID, contextID);

And calling it in my main file with:

const jiraFieldContext = await getJiraCustomFieldContexts(jiraField[0].id);

I get the following error:

node:internal/process/esm_loader:94
    internalBinding('errors').triggerUncaughtException(

when I add --trace-uncaught node --trace-uncaught ./src/index.js I get:

node:internal/process/esm_loader:94
    internalBinding('errors').triggerUncaughtException(
                              ^

Thrown at:
    at loadESM (node:internal/process/esm_loader:94:31)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)

The error is caused after using both issueCustomFieldContexts.getContextsForField and issueCustomFieldOptions.getOptionsForContext

I searched high and low, but the solutions seem to general for me to determine the cause of the error. Does anybody have any insight.

Update:

I found a possible cause: https://nodejs.medium.com/announcing-a-new-experimental-modules-1be8d2d6c2ff

I have indeed set type: module in my package.json

MrRefactoring commented 1 year ago

Hi @vichingo! At the moment we are not supporting ESM in Jira.js

vichingo commented 1 year ago

That's unfo. But I solved it. It had to do with me passing the variables in an object and try catch around it