Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Api.isIdempotencyConflict error when hosting package in Firebase Cloud Function #69

Closed
alfie-ab opened this issue May 12, 2020 · 2 comments

Comments

@alfie-ab
Copy link

Hi! I'm using firebase cloud functions to host the client and I have this simple boilerplate code set up to add a customer:

import * as functions from 'firebase-functions';
const gocardless = require('gocardless-nodejs');
const constants = require('gocardless-nodejs/constants');
import { config } from '../goCardless/config';

const goCardless = gocardless(config.token, constants.Environments.Sandbox);

export const getPaymentUrl = functions.https.onCall(
  async (session_token, success_redirect_url) => {
    try {
      const redirectFlow = await goCardless.redirectFlows.create({
        description: 'Collective',
        session_token,
        success_redirect_url
      });
      return redirectFlow;
    } catch (error) {
      console.log(error);
    }
  }
);

When I call getPaymentUrl in a local shell of firebase functions, it all works. And when I run it in a simple node/express server it also works.

However when I deploy the function to firebase I get this error:

TypeError: Cannot read property 'statusCode' of undefined     
at Api.isIdempotencyConflict (/workspace/node_modules/gocardless-nodejs/api/api.js:126:26)     at Api.request (/workspace/node_modules/gocardless-nodejs/api/api.js:58:22)    
at process._tickCallback (internal/process/next_tick.js:68:7) | more_vert

I think the error being displayed is likely hiding the actual error?

Versions:
firebase-functions: 3.6.0
gocardless-nodejs: 1.1.1
node: 10

Thanks, and let me know if you need any more info!

@lancscoder
Copy link
Contributor

lancscoder commented May 13, 2020

Hi @alfie-ab

We've just pushed version 1.1.2 to npm, this should show more details about the error rather than the:

TypeError: Cannot read property 'statusCode' of undefined     
at Api.isIdempotencyConflict (/workspace/node_modules/gocardless-nodejs/api/api.js:126:26)     at Api.request (/workspace/node_modules/gocardless-nodejs/api/api.js:58:22)    
at process._tickCallback (internal/process/next_tick.js:68:7) | more_vert

If you're still having problems just let us know.

@alfie-ab
Copy link
Author

Amazing, so v1.1.2 revealed the actual error in the firebase logs which was that since we're on the free plan firebase was blocking calls to external services. Have now upgraded and works perfectly!

Thanks so much for the quick turnaround and especially @isaacseymour for answering all my questions. Am closing the issue :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants