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

Error with ng build Angular v15.2.0 #359

Open
3 tasks done
ghost opened this issue Jul 21, 2023 · 6 comments
Open
3 tasks done

Error with ng build Angular v15.2.0 #359

ghost opened this issue Jul 21, 2023 · 6 comments

Comments

@ghost
Copy link

ghost commented Jul 21, 2023

Is there an existing issue for this?

How do you use Sentry?

Self-hosted/on-premise

Which SDK are you using?

@sentry/angular

SDK Version

7.59.3

Framework Version

Angular v15.2.0, Node v16.13.1 (also tried with Node v18)

Link to Sentry event

No response

SDK Setup

const packageJson = require('../package.json');

let appVersion;

switch (environment.name) {
    case 'stage':
        appVersion = packageJson.stageVersion;
        break;
    case 'dev':
        appVersion = packageJson.devVersion;
        break;
    case 'prod':
        appVersion = packageJson.version;
        break;
}

try {
    Sentry.init({
        environment: environment.name,
        enabled: environment.sentry.enabled,
        dsn: environment.sentry.cdn,
        release: `${process.env.npm_package_name}@${appVersion}`,
        debug: environment.sentry.debug,
        integrations: [
            new Sentry.BrowserTracing({
                // Set 'tracePropagationTargets' to control for which URLs distributed tracing should be enabled
                tracePropagationTargets: environment.sentry.tracePropagationTargets,
                routingInstrumentation: Sentry.routingInstrumentation,
                beforeNavigate: (context) => {
                    return {
                        ...context,
                        name: location.pathname.replace(UUID_REGEX, '/<hash>')
                    };
                },
            }),
            new Sentry.Replay(),
        ],
        // Performance Monitoring
        tracesSampleRate: environment.sentry.tracesSampleRate, // Capture 100% of the transactions, reduce in production!
        // Session Replay
        replaysSessionSampleRate: environment.sentry.replaysSessionSampleRate, // This sets the sample rate at 10%. You may want to change it to 100% while in development and then sample at a lower rate in production.
        replaysOnErrorSampleRate: environment.sentry.replaysOnErrorSampleRate, // If you're not already sampling the entire session, change the sample rate to 100% when sampling sessions where errors occur.
    });

    const activeTransaction = Sentry.getActiveTransaction();
    bootstrapSpan = activeTransaction
        && activeTransaction.startChild({
            description: 'platform-browser-dynamic',
            op: 'ui.angular.bootstrap',
        });
} catch (err) {
    console.error(err);
}

env

export const environment = {
    name: 'dev',
    sentry: {
        enabled: false,
        cdn: 'url_to_cdn',
        debug: true,
        tracePropagationTargets: ['devUrl', 'devApiUrl'],
        tracesSampleRate: 1,
        replaysSessionSampleRate: 0.1,
        replaysOnErrorSampleRate: 1.0,
    }
};

Steps to Reproduce

I use custom-webpack with Angular with 3 environments. But currently I'm applying Dev env only
angular.json

"architect": {
  "build": {
      "builder": "@angular-builders/custom-webpack:browser",
      "options": {
          "customWebpackConfig": {
              "mergeRules": {
                  "externals": "replace"
              },
              "replaceDuplicatePlugins": true
          }
      },
      "configurations": {
        "production": {
          "customWebpackConfig": {
            "path": "custom-webpack.config.prod.js"
          }
        },
        "stage": {
          "customWebpackConfig": {
            "path": "custom-webpack.config.stage.js"
          }
        },
        "dev": {
          "customWebpackConfig": {
            "path": "custom-webpack.config.dev.js"
          }
        }
      }         
  }
}

custom-webpack.config.dev.js

const { sentryWebpackPlugin } = require("@sentry/webpack-plugin");
const packageJson = require('./package.json');

module.exports = {
    devtool: "source-map", // Source map generation must be turned on
    plugins: [
        sentryWebpackPlugin({
            org: "myOrgName",
            project: "myProjectName",
            release: {
                name: `${process.env.npm_package_name}@${packageJson.devVersion}`
            },
            authToken: "myAuthToken",
        }),
    ],
};

When I run: npm start run build-dev with config in package.json
"build-dev": "node --max_old_space_size=8192 ./node_modules/@angular/cli/bin/ng build --configuration=dev"
Sometimes it shows error An unhandled exception occurred: socket hang up
image
with log detail:
image

Sometimes it shows error Client network socket disconnected before secure TLS connection was established
image
with log detail:
image

Sometimes it builds successfully but it stuck at the last step after building success Build at: 2023-07-21T09:55:15.124Z - Hash: a86f2728c9b24f07 - Time: 57608ms

But when I tried with another plugin, it worked perfectly. Then I back to sentry plugins, it happened again

Expected Result

Build successfully without being stuck and errors

Actual Result

Images above

@ghost ghost changed the title Error with ng build Error with ng build Angular v15.2.0 Jul 21, 2023
@Lms24
Copy link
Member

Lms24 commented Jul 24, 2023

Hi @nhan-truong255 thanks for writing in!

Which version of the @sentry/webpack-plugin are you using?

I'm not sure if this is related to whatever is causing this issue but is there a special reason why you're only using our plugin for dev builds and not for prod? Generally, our webpack plugin should primarily used for prod builds to upload source maps before you deploy your app to production/staging (or whatever environment you want to get source-mapped errors in Sentry)?

Furthermore, I'm wondering if this is related to #345. This bug was tracked down to be caused by one of our dependencies (unplugin - unjs/unplugin#323)

@ghost
Copy link
Author

ghost commented Jul 24, 2023

Hi @Lms24,
I'm using @sentry/webpack-plugin@2.4.0 (latest).
I'm applying for the Dev environment first. If it's OK, I will move on to Prod.
I think it's related to #345 that you mentioned. I'm facing the same issue.

@ghost
Copy link
Author

ghost commented Jul 27, 2023

If it helps you all
image

@Lms24
Copy link
Member

Lms24 commented Jul 31, 2023

Hi, I'm going to transfer this issue to our bundler plugins repo, as it's related to the webpack plugin. We're aware of it and we have a long term plan to move away from unplugin which is causing this issue. We'll still need to figure out if there's something we can contribute to unplugin to fix this in the meantime.

@Lms24 Lms24 transferred this issue from getsentry/sentry-javascript Jul 31, 2023
@github-actions
Copy link

This issue has gone three weeks without activity. In another week, I will close it.

But! If you comment or otherwise update it, I will reset the clock, and if you label it Status: Backlog or Status: In Progress, I will leave it alone ... forever!


"A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀

@github-actions
Copy link

This issue has gone three weeks without activity. In another week, I will close it.

But! If you comment or otherwise update it, I will reset the clock, and if you label it Status: Backlog or Status: In Progress, I will leave it alone ... forever!


"A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Waiting for: Product Owner
Development

No branches or pull requests

1 participant