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

How to run in a serverless env? #1534

Closed
ScottChapman opened this issue May 21, 2021 · 5 comments
Closed

How to run in a serverless env? #1534

ScottChapman opened this issue May 21, 2021 · 5 comments

Comments

@ScottChapman
Copy link

I am running into a problem running my Probot in IBM Cloud Functions (Openwhisk). It appears that it thinks I am running in a browser rather than running in NodeJS.

I think my issue is related to this: octokit/auth-app.js#59

When I initially ran it told me to convert my key to pkcs8. Which I did, but then I got the error that atob was not defined.

It runs perfectly locally when I am debugging.

To run this serverless I am using webpack to generate a single javascript file. My config looks like:

module.exports = {
  entry: {
    webhook: './actions/Webhook.js',
    probot: './actions/Probot.js',
  },
  target: 'node',
  output: {
    filename: '[name].js',
    path: path.resolve(__dirname, 'dist'),
  },
  optimization: {
    minimize: false
  }
};

Not sure what I am missing here...

@gr2m
Copy link
Contributor

gr2m commented May 21, 2021

maybe this workaround will work for your webpack setup?

gr2m/universal-user-agent#23 (comment)

@ScottChapman
Copy link
Author

ScottChapman commented May 21, 2021

maybe this workaround will work for your webpack setup?

gr2m/universal-user-agent#23 (comment)

Thanks, I'm not super familiar with webpack, so not clear in this case what my above config would look like? But I am willing to try a few things... I did try this (based on first comment):

const path = require('path');
const webpack = require('webpack')

module.exports = {
  entry: {
    webhook: './actions/Webhook.js',
    probot: './actions/Probot.js',
  },
  target: 'node',
  output: {
    filename: '[name].js',
    path: path.resolve(__dirname, 'dist'),
  },
  optimization: {
    minimize: false
  },
  plugins: [
    new webpack.NormalModuleReplacementPlugin(
        /universal-user-agent\/dist-web\/index\.js/,
        "../dist-src/index.js"
      )
  ]
};

and

const path = require('path');

module.exports = {
  entry: {
    webhook: './actions/Webhook.js',
    probot: './actions/Probot.js',
  },
  target: 'node',
  output: {
    filename: '[name].js',
    path: path.resolve(__dirname, 'dist'),
  },
  optimization: {
    minimize: false
  },
  resolve: {
    // ...
    alias: {
      "universal-user-agent": path.resolve(
        __dirname,
        "node_modules/universal-user-agent/dist-src/index.js"
      )
    }
  }
};

Neither worked...

@gr2m
Copy link
Contributor

gr2m commented May 21, 2021

universal-user-agent shouldn't be the problem any more, as long as you have the latest version in your dependency tree.

I think the package cause you the problem is https://github.com/gr2m/universal-github-app-jwt/

GitHub
Calculate GitHub App bearer tokens for Node & modern browsers - gr2m/universal-github-app-jwt

@ScottChapman
Copy link
Author

ScottChapman commented May 21, 2021

universal-user-agent shouldn't be the problem any more, as long as you have the latest version in your dependency tree.

I think the package cause you the problem is https://github.com/gr2m/universal-github-app-jwt/

I'm running universal-user-agent@6.0.0 and universal-github-app-jwt@1.1.0 which both look pretty current.

not sure how to resolve this (stuck on Node v12)

@gr2m
Copy link
Contributor

gr2m commented Jul 9, 2021

This is a build issue outside of the scope of probot. Now that we have ES Modules and a standard from Node on conditional exports, that problem should go away for good once we move to it. But that will take a while.

A good issue to follow is octokit/octokit.js#2128. Once we finished migrating all Octokit packages, we can migrate probot as well

@gr2m gr2m closed this as completed Jul 9, 2021
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

3 participants
@gr2m @ScottChapman and others