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

Output file tracing - server.js compression false #33696

Closed
thomasledoux1 opened this issue Jan 26, 2022 · 1 comment · Fixed by #33717
Closed

Output file tracing - server.js compression false #33696

thomasledoux1 opened this issue Jan 26, 2022 · 1 comment · Fixed by #33717
Labels
bug Issue was opened via the bug report template. Output (export/standalone) Related to the the output option in `next.config.js`.

Comments

@thomasledoux1
Copy link

Run next info (available from version 12.0.8 and up)

Operating System:
  Platform: darwin
  Arch: x64
  Version: Darwin Kernel Version 20.6.0: Tue Oct 12 18:33:42 PDT 2021; root:xnu-7195.141.8~1/RELEASE_X86_64
Binaries:
  Node: 16.11.0
  npm: 8.0.0
  Yarn: N/A
  pnpm: N/A
Relevant packages:
  next: 12.0.8
  react: 17.0.2
  react-dom: 17.0.2

What version of Next.js are you using?

12.0.8

What version of Node.js are you using?

16.11.0

What browser are you using?

Chrome

What operating system are you using?

macOS

How are you deploying your application?

Docker on Azure

Describe the Bug

We are currently using the automatic copying of traced files from the output standalone (https://nextjs.org/docs/advanced-features/output-file-tracing#automatically-copying-traced-files-experimental).
This is working great so far.
We are using the generated server.js to serve our application.
However, we noticed our resources were not being compressed automatically anymore, which was the case when we were still using next start before.
When I have a look in the server.js file which is generated, I noticed that the compress configuration option was false by default.
Is there a way to overwrite this?
Wouldn't it be more logical to put compress on true by default?

Server.js contents:

process.env.NODE_ENV = 'production'
process.chdir(__dirname)
const NextServer = require('next/dist/server/next-server').default
const http = require('http')
const path = require('path')

let handler

const server = http.createServer(async (req, res) => {
  try {
    await handler(req, res)
  } catch (err) {
    console.error(err)
    res.statusCode = 500
    res.end('internal server error')
  }
})
const currentPort = parseInt(process.env.PORT, 10) || 3000

server.listen(currentPort, err => {
  if (err) {
    console.error('Failed to start server', err)
    process.exit(1)
  }
  const addr = server.address()
  const nextServer = new NextServer({
    hostname: 'localhost',
    port: currentPort,
    dir: path.join(__dirname),
    dev: false,
    conf: {
      env: {},
      webpack: null,
      webpackDevMiddleware: null,
      eslint: {ignoreDuringBuilds: false},
      typescript: {ignoreBuildErrors: false, tsconfigPath: 'tsconfig.json'},
      distDir: './.next',
      cleanDistDir: true,
      assetPrefix: '',
      configOrigin: 'next.config.js',
      useFileSystemPublicRoutes: true,
      generateEtags: true,
      pageExtensions: ['tsx', 'ts', 'jsx', 'js'],
      target: 'server',
      poweredByHeader: true,
      compress: true,
      analyticsId: '',
      images: {
        deviceSizes: [640, 750, 828, 1080, 1200, 1920, 2048, 3840],
        imageSizes: [16, 32, 48, 64, 96, 128, 256, 384],
        path: '/_next/image',
        loader: 'default',
        domains: [
          'assets-eu-01.kc-usercontent.com',
          'preview-assets-eu-01.kc-usercontent.com',
        ],
        disableStaticImages: false,
        minimumCacheTTL: 60,
        formats: ['image/webp'],
      },
      devIndicators: {
        buildActivity: true,
        buildActivityPosition: 'bottom-right',
      },
      onDemandEntries: {maxInactiveAge: 15000, pagesBufferLength: 2},
      amp: {canonicalBase: ''},
      basePath: '',
      sassOptions: {},
      trailingSlash: false,
      i18n: {defaultLocale: 'en', locales: ['en', 'nl']},
      productionBrowserSourceMaps: false,
      optimizeFonts: true,
      excludeDefaultMomentLocales: true,
      serverRuntimeConfig: {},
      publicRuntimeConfig: {},
      reactStrictMode: false,
      httpAgentOptions: {keepAlive: true},
      outputFileTracing: true,
      staticPageGenerationTimeout: 60,
      swcMinify: false,
      experimental: {
        cpus: 11,
        sharedPool: true,
        plugins: false,
        profiling: false,
        isrFlushToDisk: true,
        workerThreads: false,
        pageEnv: false,
        optimizeImages: false,
        optimizeCss: false,
        scrollRestoration: false,
        externalDir: false,
        reactRoot: false,
        disableOptimizedLoading: false,
        gzipSize: true,
        swcFileReading: true,
        craCompat: false,
        esmExternals: true,
        isrMemoryCacheSize: 52428800,
        concurrentFeatures: false,
        serverComponents: false,
        fullySpecified: false,
        outputFileTracingRoot: '',
        outputStandalone: true,
      },
      configFileName: 'next.config.js',
    },
  })
  handler = nextServer.getRequestHandler()

  console.log('Listening on port', currentPort)
})

Expected Behavior

I would like an option to overwrite the compress configuration, or to have compress on true by default

To Reproduce

Put this in next.config.js:

experimental: {
    outputStandalone: true,
},

Execute npm run build, and check the server.js file in .next/standalone

@thomasledoux1 thomasledoux1 added the bug Issue was opened via the bug report template. label Jan 26, 2022
@balazsorban44 balazsorban44 added the Output (export/standalone) Related to the the output option in `next.config.js`. label Jan 26, 2022
@kodiakhq kodiakhq bot closed this as completed in #33717 Jan 27, 2022
kodiakhq bot pushed a commit that referenced this issue Jan 27, 2022
Fixes #33696

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes by running `yarn lint`
natew pushed a commit to natew/next.js that referenced this issue Feb 16, 2022
Fixes vercel#33696

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes by running `yarn lint`
@github-actions
Copy link
Contributor

This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 26, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue was opened via the bug report template. Output (export/standalone) Related to the the output option in `next.config.js`.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants