repack icon indicating copy to clipboard operation
repack copied to clipboard

Unable to start server

Open omotayoR1 opened this issue 2 years ago • 11 comments

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

omotayoR1 avatar Apr 08 '24 12:04 omotayoR1

@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 avatar Apr 08 '24 12:04 jbroma

@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

omotayoR1 avatar Apr 08 '24 14:04 omotayoR1

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

jbroma avatar Apr 08 '24 14:04 jbroma

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

omotayoR1 avatar Apr 09 '24 11:04 omotayoR1

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

jbroma avatar Apr 10 '24 13:04 jbroma

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

Okay

Thanks for helping

omotayoR1 avatar Apr 12 '24 10:04 omotayoR1

@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

paaber avatar Apr 15 '24 20:04 paaber

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

jbroma avatar Apr 15 '24 21:04 jbroma

@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

jbroma avatar Apr 17 '24 14:04 jbroma

@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

omotayoR1 avatar Apr 19 '24 12:04 omotayoR1

@omotayoR1 please open a new issue

jbroma avatar Apr 19 '24 13:04 jbroma