Coder Social home page Coder Social logo

Unable to start server about repack HOT 11 CLOSED

omotayoR1 avatar omotayoR1 commented on June 21, 2024
Unable to start server

from repack.

Comments (11)

jbroma avatar jbroma commented on June 21, 2024

@omotayoR1 I have no access to Windows right now and have no way to check for a fix.

My best guess is that somehow path in C:\Users\directory\Documents\d\node_modules@callstack\repack-dev-server\dist\plugins\faviconPlugin.js evaluates incorrectly, you can try adjust it to see if it resolves this.

from repack.

omotayoR1 avatar omotayoR1 commented on June 21, 2024

@omotayoR1 I have no access to Windows right now and have no way to check for a fix.

My best guess is that somehow path in C:\Users\directory\Documents\d\node_modules@callstack\repack-dev-server\dist\plugins\faviconPlugin.js evaluates incorrectly, you can try adjust it to see if it resolves this.

I checked the path mentioned and on line 24, it seems something is wrong there const fp = require('fastify-plugin')

What's the resolution please

Thanks for helping

from repack.

jbroma avatar jbroma commented on June 21, 2024

@omotayoR1 could you provide a snippet? I see the file has only like 15 LOC

from repack.

omotayoR1 avatar omotayoR1 commented on June 21, 2024

@omotayoR1 could you provide a snippet? I see the file has only like 15 LOC

/*

  • Copyright 2018-2023 the original author or authors.
  • Licensed under the Apache License, Version 2.0 (the "License");
  • you may not use this file except in compliance with the License.
  • You may obtain a copy of the License at
  • http://www.apache.org/licenses/LICENSE-2.0
    
  • Unless required by applicable law or agreed to in writing, software
  • distributed under the License is distributed on an "AS IS" BASIS,
  • WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  • See the License for the specific language governing permissions and
  • limitations under the License.
    */
    'use strict'

/**

  • Plugin:
  • this module exports the plugin as a function.
  • @module plugin
    */

const fp = require('fastify-plugin')
const pn = require('node:path')
const fs = require('node:fs')

const iconNameDefault = 'favicon.ico'

/**

  • Plugin implementation.
  • @param {!object} fastify Fastify instance
  • @param {!object} options plugin configuration options
    • <li>path (string, default `__dirname`) for the folder containing the icon,</li>
      
    • <li>name (string, default 'favicon.ico') for favicon file name,</li>
      
    • <li>maxAge (number, default 86400) for cache duration in seconds for the image,</li>
      
  • @param {!function} done callback, to call as last step
  • @namespace
    */
    function fastifyFavicon (fastify, options, done) {
    const {
    path = __dirname,
    name = iconNameDefault,
    maxAge = 86400
    } = options

ensureIsString(path, 'iconPath')
ensureIsString(name, 'iconName')
ensureIsInteger(maxAge, 'maxAge')

const icon = pn.join(path, name)

fs.readFile(icon, (err, faviconFile) => {
if (err) {
if (err.code === 'ENOENT') {
done(new Error(fastify-favicon: ${icon} not found))
return
}

  done(new Error(`fastify-favicon: Could not load ${icon}`))
  return
}

fastify.get(`/${name}`, faviconRequestHandler(faviconFile))
done()

})

/**

  • Factory for the request handler for the favicon.
  • @param {!object} file the icon file to send in the response
  • @return {function} the handler function, preconfigured with plugin settings and the file to send
  • @inner
    */
    function faviconRequestHandler (file) {
    const cacheHeader = max-age=${maxAge}
    return function handler (_fastifyRequest, fastifyReply) {
    fastifyReply
    .header('cache-control', cacheHeader)
    .type('image/x-icon')
    .send(file)
    }
    }
    }

// utility functions

function ensureIsString (arg, name) {
if (arg !== null && typeof arg !== 'string') {
throw new TypeError(The argument '${name}' must be a string, instead got a '${typeof arg}')
}
}
function ensureIsInteger (arg, name) {
if (arg !== null && typeof arg !== 'string' && Number.isFinite(arg) === false && Number.isInteger(arg) === false) {
throw new TypeError(The argument '${name}' must be an integer)
}
}

module.exports = fp(fastifyFavicon, {
fastify: '4.x',
name: 'fastify-favicon'
})

from repack.

jbroma avatar jbroma commented on June 21, 2024

@omotayoR1 FYI, I should be able to investigate this on Windows by the end of the week

from repack.

omotayoR1 avatar omotayoR1 commented on June 21, 2024

@omotayoR1 FYI, I should be able to investigate this on Windows by the end of the week

Okay

Thanks for helping

from repack.

paaber avatar paaber commented on June 21, 2024

@jbroma have you been able to investigate this ?

@omotayoR1 FYI, I should be able to investigate this on Windows by the end of the week

from repack.

jbroma avatar jbroma commented on June 21, 2024

@paaber yes, the investigation is ongoing and we're working on a fix together with @szymonrybczak

from repack.

jbroma avatar jbroma commented on June 21, 2024

@omotayoR1 @paaber we've just released @callstack/repack 4.0.0-rc.1, your issues should be resolved now :)

Btw, you can now install Re.Pack in new projects with custom version like this:

npx @callstack/repack-init@rc --custom-version 4.0.0-rc.1

from repack.

omotayoR1 avatar omotayoR1 commented on June 21, 2024

@omotayoR1 @paaber we've just released @callstack/repack 4.0.0-rc.1, your issues should be resolved now :)

Btw, you can now install Re.Pack in new projects with custom version like this:

npx @callstack/repack-init@rc --custom-version 4.0.0-rc.1

Thanks for helping. The server starts now and builds successfully but it stops bundling at some point and it throws this error
Error [ERR_UNHANDLED_ERROR]: Unhandled error. ({})
at Compiler.emit (node:events:508:17)
at Worker. (C:\Users\directory\Documents\anotherHastro\node_modules@callstack\repack\dist\webpack\Compiler.js:97:14)
at Worker.emit (node:events:519:28)
at MessagePort. (node:internal/worker:263:53)
at [nodejs.internal.kHybridDispatch] (node:internal/event_target:822:20)
at exports.emitMessage (node:internal/per_context/messageport:23:28) {
code: 'ERR_UNHANDLED_ERROR',
context: {}
}

Node.js v21.4.0

Please help me look into it

Thanks

from repack.

jbroma avatar jbroma commented on June 21, 2024

@omotayoR1 please open a new issue

from repack.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.