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

Unable to start server #548

Closed
omotayoR1 opened this issue Apr 8, 2024 · 11 comments · Fixed by #554
Closed

Unable to start server #548

omotayoR1 opened this issue Apr 8, 2024 · 11 comments · Fixed by #554
Labels
area:repack The issue is about logic/code inside of Re.Pack. area:windows Issues happening on Windows type:bug A bug report.

Comments

@omotayoR1
Copy link

I upgraded re.pack to @4.0.0-rc.0 and i'm not able to start the server by running 'npx react-native webpack-start' again. The error i'm getting below;

error fastify-favicon: \C:\Users\directory\Documents\d\node_modules@callstack\repack-dev-server\dist\img\favicon.ico not found.
Error: fastify-favicon: \C:\Users\directory\Documents\d\node_modules@callstack\repack-dev-server\dist\img\favicon.ico not found
at ReadFileContext. (C:\Users\directory\Documents\d\node_modules\fastify-favicon\src\plugin.js:60:14)
at ReadFileContext.callback (C:\Users\directory\Documents\d\node_modules\graceful-fs\graceful-fs.js:123:16)
at FSReqCallback.readFileAfterOpen [as oncomplete] (node:fs:306:13)

what do i do

Thanks for helping

@jbroma
Copy link
Member

jbroma commented Apr 8, 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.

@jbroma jbroma added type:bug A bug report. area:repack The issue is about logic/code inside of Re.Pack. area:windows Issues happening on Windows labels Apr 8, 2024
@omotayoR1
Copy link
Author

@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

@jbroma
Copy link
Member

jbroma commented Apr 8, 2024

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

@omotayoR1
Copy link
Author

@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'
})

@jbroma
Copy link
Member

jbroma commented Apr 10, 2024

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

@omotayoR1
Copy link
Author

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

Okay

Thanks for helping

@paaber
Copy link

paaber commented Apr 15, 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

@jbroma
Copy link
Member

jbroma commented Apr 15, 2024

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

@jbroma
Copy link
Member

jbroma commented Apr 17, 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

@omotayoR1
Copy link
Author

@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

@jbroma
Copy link
Member

jbroma commented Apr 19, 2024

@omotayoR1 please open a new issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:repack The issue is about logic/code inside of Re.Pack. area:windows Issues happening on Windows type:bug A bug report.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants